l293d is not able to drive two 300 rpm motors simultaneously

Check if both channels are working in either direction individually.
Check the current draw under the load per motor using an Digital Multimeter as an Ammeter function.

The L293 is designed to provide bidirectional drive currents of up to 1A at voltages from 4.5V to 36V.
600mA per channel for L293D

As long as your motors at drawing more than 600mA per motor, it should work fine.


NeoPixel setPixelColor works only in for loop

I am not sure I fully understand your exact problem but you have to be aware that holo_pxl.setPixelColor(1, c); set the color of the second LED in a NeoPixel chain, NOT the first one.

For the first LED, you have to use holo_pxl.setPixelColor(0, c); instead.


Specify F_CPU in arduino to use 8MHz clock

No, the boards.txt file is where it is defined and the only place it is (or can be) defined. Making a new board variant is the proper way of adding a new board with new settings.


arduino leonardo stops transmitting once hdmi cable is connected to a screen

The issue is that the mouse coordinates are being set by the display device that it's attached to.
The computer sends a descriptor about the display to the HID device ( the mouse ) the mouse then uses the information about the logical size of the screen to co-ordinate the movements.
For example, to move with Mouse.move(100,100,0); you are not actually moving by 100 pixels, but by 100/(127-((-127)).
The only option is can suggest is to STOP the mouse and Restart it again - this will be easier to restart calculations again.
Heres my Logic Function to convert Percentage to appropriate values for Mouse.move();
int percentToLogic(int percent) { return percent*254/100; }


Has anybody used an Arduino board to host an interactive web page, including user input via Submit / Form ?

I have a Tiny Web Server for the Arduino. It is designed to be light-weight on RAM. It supports GET/POST/Cookies for interacting with web forms.

Example code and more information on the linked page above.

  (Can I declare a local network static IP address for an Arduino?)

Yes.

  Other comments?

You could use NRF24L01 modules for short-range communication of wireless information. I have example code and schematics. My tests seemed to indicate 20m range was achievable.


What's the point of a USB to Serial converter in Arduino Uno?

The problem with your understanding is with what "COM" is.

"COMx" is not a physical serial port - it is merely a concept. It is a "serial device" in Windows.

That Serial Device is implemented as a CDC/ACM protocol on USB. It's not "converted" - "COMx" is just the visible interface to the PC's end of the CDC/ACM connection.

The ATMega328P chip (and the ATMega2560) can't talk USB directly. They talk UART. So UART data is sent to another chip that can talk both USB and UART to bridge the two technologies.

So from the PC perspective the chain is:

CDC/ACM Driver ("COMx") => USB => ATMega16U2 => UART => ATMega328P

Boards with an ATMega32U4 chip on them, like the Leonardo, can talk USB directly - so the sequence is much shorter:

CDC/ACM Driver ("COMx") => USB -> ATMega32U4

Again there is no conversion from "COMx" to "USB" since "COM" is just the name given to the exposed end of the CDC/ACM driver.

It can be said that CDC/ACM emulates a serial port over USB. It forms a channel between the CDC/ACM driver ("COMx") and a pair of bulk endpoints in the chip at the other end of the connection.


On the ESP8266 there's very little to choose from between the two. It all really boils down to what you want to store and how you best want to access it.

EEPROM emulation is ideal for small bits of data - configuration values and that sort of thing. Where you just want to store a few of values that would seldom change.

SPIFFS though is better at dealing with large amounts of data. Since it's a filesystem it can store actual files, and that makes it ideal for serving images and static data for web pages, for example.

A SPIFFS filesystem can be built on your PC from files of your choice and then uploaded over serial using mkspiffs and esptool.py or the SPIFFS tool that can be installed into the Arduino IDE. That means the files are very easy to update.

SPIFFS is not so great when it comes to writing data though - experiments have shown that it gets quite slow when writing often.  EEPROM doesn't suffer from such a problem, but then you can't write as much data to EEPROM as you can to SPIFFS.

So that's really all there is to it. Neither is "better" than the other, but each is better suited to different ways of working or to different styles of data.


FT232RL Chip pinout to flash Arduino Pro Mini

This is the standard FTDI Basic connections. CTS is an input to the module and is typically just connected to Gnd as seen on the right side here from the Arduino Promini schematic (so the FT232 is always Clear(ed) To Send, i.e. no flow control is used).

DTR may be broken out on one of the side holes.  RTS may work for you in place of DTR to create the reset pulse to start the bootloader code.  If not,  you may have to cut the trace and wire the RTS header pin to DTR. DTR is pin 2 on the FT232, use a meter and confirm it goes to one of the side holes, that way  you don't  have to try a solder a wire on to a pin.


Probably a mistranslation of soldering. As far as I can tell, it just means that the headers are not soldered on.

(see https://www.aliexpress.com/store/product/Nano-V3-0-ATMEGA328P-improved-welding-plate-without-wiring-module-board/630494_32807228948.html for one with "welding plate")


This Instructables post has a list of potential causes for this error. Is this a new board? What board are you using? Is it a genuine Arduino board or a clone? Have you been able to upload to the board previously?


How to program an Arduino Uno Pro with a makefile?

After you edit your boards.txt file to incorporate the Arduino Uno Pro section from near the end of that Arduino Uno Pro webpage at hobbytronics.co.uk that you referenced, the board tag list produced by make show_boards will include the following line:

uno_pro       Arduino Uno*Pro

indicating the tag should be uno_pro.


max7219 chained display showing text only on the first display

Communicating with more than one MAX7219 chip when cascaded involves sending data to all the chips at once. You have to treat the cascaded sequence of chips as a single entity - an entire display in its own right.

With one chip you send an 8-bit register value followed by an 8-bit data value. To use two chips you have to send twice that - an 8-bit register and 8-bit data for the second chip, followed by an 8-bit register and 8-bit data for the first chip.

The chips have a "NO-OP" register (0x00) which can be used to ensure that nothing is done on that chip if you don't want to change anything.

So setting line 3 to 0x55 on the first display, and line 5 to 0xAA on the second display you would send the sequence \ 0x05,0xAA,0x03,0x55 / as a single transaction (lower CS \ before, raise it / afterwards).

If you only wanted to set line 2 on the second display to 0x69 you would send the sequence: \ 0x02,0x69,0x00,0x00 /

For three chips you need to send three blocks of 8+8 values. For four chips, 4 blocks of 8+8. Etc.

Note that it is important to send enough data for all the chips - you can't shortcut and only send data for the first display if that is all you want to talk to, since whatever is currently in the first display's shift register will get sent out to successive chips, and you will get the display duplication as seen in the other question.


Issues uploading to atmega324pb w/ adruino as ISP

In case anyone was wondering, I solved the problem.
Unfortunately I wasn't able to figure out how to upload it using Arduino as ISP, but I was able to get it to work with an AVR Pocket Programmer from Sparkfun. If you decide to use this, check out this drivers guide. It will It'll save massive headache getting the usb device to be recognized.

IMPORTANT FOR ATMEGA324PB USERS!!!
The atmega324pb is apparently not a default microcontroller in avrdude. You need to add it to the toolchain manually. You can do this by following this blog:
https://hackaday.io/project/9313-uino-mini-super-atmega328pb/log/31003-easy-way-to-a-toolchain-for-the-atmega328pb
It is the same process to add any Microchip microcontroller to avrdude, so this guide will work for the atmega324pb (did it firsthand). From there, you can also add a custom entry to Arduino's boards.txt config file if you'd like to use the Arduino IDE for development. I didn't mind working the command line, but having it in Arduino definitely streamlines the proccess of compiling the .hex and uploading it in one go.

Here is the custom entry I added to Arduino's boards.txt file for the Atmega324pb. All the data was gathered from the datasheet:

####   ATmega324PB    ####
m324p.name=Atmega324pb
m324p.upload.via_ssh=true

m324p.vid.0=0x0424
m324p.pid.0=0x2740

m324p.upload.tool=avrdude
m324p.upload.protocol=usbtiny
m324p.upload.maximum_size=28672
m324p.upload.maximum_data_size=2560
m324p.upload.speed=57600
m324p.upload.disable_flushing=true
m324p.upload.use_1200bps_touch=true
m324p.upload.wait_for_upload_port=true

m324p.bootloader.tool=avrdude
m324p.bootloader.low_fuses=0x62
m324p.bootloader.high_fuses=0xD9
m324p.bootloader.extended_fuses=0x0f

m324p.build.mcu=atmega324pb
m324p.build.f_cpu=1000000L
m324p.build.vid=0x0424
m324p.build.pid=0x2740
m324p.build.usb_product="Arduino m324pb"
m324p.build.board=AVR_m324pb
m324p.build.core=arduino
m324p.build.variant=standard
m324p.build.extra_flags={build.usb_flags}

Note that I set the upload.tool to avrdude, and the upload.protocol to usbtiny since I was using the pocket AVR programmer.

IMPORTANT!!!  The high fuse bit in this config also is 0xD9, instead of the default 0x99. I changed one fuse bit to disable JTAG and regain access to GPIO pins. To my knowledge Arduino wasn't setting fuse bits when uploading with the programmer, but this is an important note to take. If you need to use GPIO pins that share JTAG functionality, run the avrdude command line to set the high fuse bit appropriately. (0xD9 for me).


Does the SPI library use the internal USART?

I had a look at the source code for the SPI library. As suspected, it does not use the internal ATMega328 USART. This is useful to know because it means that the USART remains potentially available for other uses in any sketch that is using SPI. I suppose that it also makes the SPI library more portable because perhaps not all arduinen microcontrollers have a built-in USART


The jd-vcc pin can be used to power the relay coils using a separate 5V power supply. Why would you want to do that? Each relay coil draws about 73mA @ 5VDC when energized. Theres a circuit schematic on this website: http://howtomechatronics.com/tutorials/arduino/control-high-voltage-devices-arduino-relay-tutorial/


Collision detection on I2C is fully supported (See I2C Multi-Master). It works basically by attempting to transmit something and reading what is being transmitted at the same time. If what is read matches what is transmitted then the transmission worked. If it didn't match then there was a collision.

It is usually performed on a per-bit basis:

If a 0 then pull the data line LOW. If a 1 then let the resistor pull the data line HIGH.
Read the data line. If you want a 1 and get a 0 then some other device is pulling the data line low for a 0.
If the value was wrong then stop your transmission and back off by a random amount. Retry again. (note: both ends may retry, so you need good random numbers).

There is no support in the Wire library for collision detection, though, so you will have to implement it yourself. Section 22.4 of the datasheet gives you more information about how to implement it.


How to run my IDUINO Yun Shields stand-alone?

Yes, you can. All you need do is provide it with a regulated 5V supply on the 5V pin and it should power up and boot.

There's not a lot of IO on it though, so connecting to sensors and such would be hard, which is where the Arduino comes in handy. You communicate using the UART, so any microcontroller with a UART can be connected to it.


If you are powering the arduino via usb try not to do that or plug it in to an usb 3.0 (and higher) port. The reason for this is that the servo draws a lot of power and the standard usb 2.0 with 0.5A can't handle the load and you got an voltage drop. And in that period of time the led goes off. usb 3.0 (and higher) can handle up to 1.5A so this souldn't be an error.


Why is my circuit working only when I touch it?

Sounds like you have guessed it: although it's very hard to say from those photos, it doesn't look like you have the circuit grounded.

Connect a ground from the Arduino to the black wire from the battery.


How to send HTTP requests using wifi of Arduino Primo board?

With Arduino Primo use the WiFi Link library. Look at WiFi Link Examples in IDE menu.

Arduino org web archive pages


issue fixed: I adjusted the Anode (pin15) instead of the contrast (pin3).

Look at the conversation between me and Majenko to see the realisation.


How to check my Arduino board is working or dead?

Note : After the @Ricardo's comment on my last post, I am posting this !

Plug the board into a USB port on your computer and check that the green LED power indicator on the board illuminates. Standard Arduino boards (Uno, Duemilanove, and Mega) have a green LED power indicator located near the reset switch.

An orange LED near the center of the board (labeled “Pin 13 LED” in the image below) should flash on and off when the board is powered up (boards come from the factory preloaded with software to flash the LED as a simple check that the board is working).

If the power LED does not illuminate when the board is connected to your computer, the board is probably not receiving power.

The flashing LED (connected to digital output pin 13) is being controlled by code running on the board (new boards are preloaded with the Blink example sketch). If the pin 13 LED is flashing, the sketch is running correctly, which means the chip on the board is working. If the green power LED is on but the pin 13 LED is not flashing, it could be that the factory code is not on the chip. If you are not using a standard board, it may not have a built-in LED on pin 13, so check the documentation for details of your board.

Online guides for getting started with Arduino are available at for Windows,  for Mac OS X, and for Linux.


The DHT11 is a digital component with its own digital communication protocol.

Analog pins can be used for either analog input or digital input and output.

You can use a digital device like the DHT11 on any pin, whether it is labelled analog or digital (except on a couple of boards which have a few analog-only pins).


If all are handled the same and they don't have individual names, arrays and for loops are what you are looking for.

const byte relayPins[] = { A5, A4, A3, A2, A1, A0};
const byte ledPin = 3;
const byte swPins[] = {5, 6, 7, 8, 9};

void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  for (const byte relayPin: relayPins) pinMode(relayPin, OUTPUT);
  for (const byte swPin: swPins) pinMode(swPin, INPUT_PULLUP);
}

Even arduino C++ nowadays understands the foreach syntax.

BTW: for your final pin count you'll need other/additional hardware. Either a Mega or shift registers or port expanders.


How to assign a string-variable to a StackString based on the StackString-library?

StackString doesn't know what a String is.  The append function only accepts a const char *, a const char or an int:

void append(const char* string);
void append(const char character);
void append(int number);

You can get a const char * from a String easily enough with .c_str(), so use that in the append:

myString.append(NormalString.c_str());

There is also no simple assignment (or complete content replacement) with StackString - you have to "clear" the string first.  So to replace the content with what is in NormalString you would:

myString.clear();
myString.append(NormalString.c_str());


You may have noticed that this product is no longer available from well known parts distributors like adafruit.com, sparkfun.com or trossenrobotics.com. I would recommend using a Sharp distance sensor designed for the distances you are interested in:

It is about 10 times the price, but produces a variable voltage that you can read with the Arduino's ADC.  Then you can compensate for floor irregularities in your code.

If you care to experiment, I obsurved that the better distance measurement devices angle the emitter and sensor to light up & observe the same spot at the desired operating distance:

You might try this with your current sensor.  However, it does not appear the manufacture left you enough lead length to make such an adjustment.


The upgrade firmware on the ESP8266 is hardcoded. Attempting to reflash it with known good firmware should restore functionality.


Is there something I can use to control Arduinos easily over Ethernet with .NET?

I don't use .net but I have done this using php website to control a door lock over ethernet.

My solution was to use the ethernet to recieve commands and be able to use them on the arduino through http calls. And when it was done send a http call back to the server with some data. I was doing a door lock program for example. Please ignore anything talking about doors, locking, unlocking, or other requirements to certain calls, I am just providing examples about how it COULD be used, not that you need to include my door lock code in your project to get it to work.

As far as how that works out with .net that's up to you, however I can give you a hand getting your messages back and forth.

first you want to create the ethernet connection to your router. put this in your header section.

#include <UIPEthernet.h>
// assign a MAC address for the ethernet controller.
// fill in your address here:
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};

// fill in an available IP address on your network here,
// for manual configuration:
IPAddress ip(127, 0, 0, 1);

// initialize the library instance:
EthernetClient client;

char server[] = "www.example.com";
//IPAddress server(127,0,0,1);  // numeric IP for www.example.com (no DNS)

int waitTime = 3L;

unsigned long lastConnectionTime = 0;             // last time you connected to the server, in milliseconds
const unsigned long postingInterval = waitTime * 1000L; // delay between updates, in milliseconds
// the "L" is needed to use long type numbers

throw this in your main loop so it doesn't constantly make http requests spamming a server.

// if ten seconds have passed since your last connection,
// then connect again and send data:
if (millis() - lastConnectionTime > postingInterval || buttonState == 0) {
  httpRequest();
}

Create a method to handle httpRequest because shoving everything under the main is kinda sloppy.

Alright so there will be quite a bit here because http headers are kinda lengthy.

// this method makes a HTTP connection to the server:
void httpRequest() {
  // close any connection before send a new request.
  // This will free the socket on the WiFi shield
  client.stop();
  // if there's a successful connection:
  if (client.connect(server, 80)) {
    Serial.println("connecting...");
    // send the HTTP PUT request:
  Serial.println("String is " + readString);
  if(readString == "Ready" || readString == ""){
    client.println("GET /command.txt HTTP/1.1");
    where = "web";
    waitTime = 5L;
  }
  else{
    // here is the basic format of sending a get command
    //this specific request is so that I can tell where the command came from. I had a web client / mobile app that could control the door AND you could also control it from a physical buttom. The door would have to reply either way to the web server (READ: .net application) in order to have the correct status always show up on the web end.

    client.print("GET /update.php?where=Arduino&command=Ready&status=");
    if(readString == "Reset"){
      client.print("Reset");
    }
    else if(isLocked){
      client.print("Locked");
    }
    else{
      client.print("Unlocked");
    }
    client.println(" HTTP/1.1");
    waitTime = 1L;
  }
  client.println("Host: www.example.com");
  client.println("User-Agent: arduino-ethernet");
  client.println("Connection: close");
  client.println();

    // note the time that the connection was made:
    lastConnectionTime = millis();
  }
  else {
    // if you couldn't make a connection:
    Serial.println("connection failed");
  }
}

TL;DR if you wanna use ethernet you need to use all of ethernet.
Start by creating your connection to the router statically (watch for conflicts).

Then create a method of watching for incoming data or waiting for a command if there isn't one. (server call).

Then create A FULL HTTP REQUEST in order to pass your request through. Shorting any parts of this last part and you will either end up with bad request errors or will simply fail.

Let me know if you need anything else or if this was useful to you!


Value of the counter collide on my lcd while decreasing. How can I remove it?

A simple option would be to call lcd.clear() at the start of loop(). That will clear the entire LCD display. Everything else should work fine because it looks like you're outputting the entire display contents every time round.

Alternatively, you could remove the extra digit by printing a space over it, e.g.:

if (visitor < 10) print(" ");
lcd.print(visitor);

If visitor is a 1-digit number (i.e. less than 10), it will output a space at the start, getting rid of any underlying digits leftover from a previous iteration. If you want the number to be left-aligned then you could print the space after the number instead.


I asked this question to be moved to Stackoverflow as it is not Arduino related.

However to answer your question, you assign the booleans before you start the program, so they are never re-evaluated and always keep their initial value, based on when x = 0.

What you should do is, reevaluate them within the loop:

int x = 0;
boolean state1;
boolean state2;

void setup() {
  Serial.begin(9600);
}

void loop() {
  x++;
  state1 = (x <= 10);
  state2 = (x > 10);
  if (state1) {
    Serial.println("x <= 10");
  } else if (state2) {
    Serial.println(" x > 10");
  }
}

Also, because if state1 is true, state2 will always be false and vice versa, so you don't need to have two booleans. This will give:

int x = 0;
boolean state;

void setup() {
  Serial.begin(9600);
}

void loop() {
  x++;
  state = (x <= 10);
  if (state) {
    Serial.println("x <= 10");
  } else {
    Serial.println(" x > 10");
  }
}

Beyond that, you don't need to define the boolean globally, because you only need it inside the loop and is not need to be 'stored' from one loop to another. So you get

int x = 0;

void setup() {
  Serial.begin(9600);
}

void loop() {
  x++;
  boolean state = (x <= 10);
  if (state) {
    Serial.println("x <= 10");
  } else {
    Serial.println(" x > 10");
  }
}

Of course you can also directly check for x <= 10 instead of storing it in a boolean, but I assume you need the boolean elsewhere further within the loop function later.


How to implement elapsed millis as the timer for my motor spinning time?

delay() is only the tip of the iceberg. The problem with delay() is
that it is a blocking function: nothing else can be done during the
delay. If you want to control your motor and at the same time be
responsive to the user, you must avoid blocking your program. This means
not only getting rid of delay(), but also getting rid of any blocking
function.

Here your problem is on getTheNumber(). This function blocks until the
user is done typing the number. Try to rewrite it in a non-blocking
fashion. For example, it could return -1 on every call as long as the
user is not done typing the number. On the first call after the user is
done it would return the valid value. If you manage to write everything
non-blocking, then you loop() will restart very often, and the program
will work with no significant latency.

As for managing the servo stages, simplest thing  would be to write a
finite state machine. I would write it with four states: IDLE,
STAGE1, STAGE2 and STAGE3. The transitions STAGE1 → STAGE2 → STAGE3 →
IDLE would be time-based, using the elapsedMillis object to track the
time spent in each state. The transition IDLE → STAGE1 would be
triggered by the user input.

static enum { IDLE, STAGE1, STAGE2, STAGE3 } state;
switch (state) {
    case IDLE:
        if (userRequestedToStartAgain()) {
            myservo.write(stage1speed);
            state = STAGE1;
            timeElapsed = 0;
        }
        break;
    case STAGE1:
        if (timeElapsed >= stage1time) {
            myservo.write(stage2speed);
            state = STAGE2;
            timeElapsed = 0;
        }
        break;
    case STAGE2:
        if (timeElapsed >= stage2time) {
            myservo.write(stage3speed);
            state = STAGE3;
            timeElapsed = 0;
        }
        break;
    case STAGE3:
        if (timeElapsed >= stage3time) {
            myservo.write(idleValue);
            state = IDLE;
        }
        break;
}


Can the Arduino Due be used as a serial to USB converter?

Yes it will work as a USB to serial device, however the serial will be at 3.3V not 5V. It'll still be serial though.

For it to send data to a 5V device, depending on the device, it might work.  3.3V is often around the "high" threshold for an input pin on a 5V device, but check the datasheet for the 5V device to be sure.

For receiving data the 5V will be above the 3.3V supply voltage of the main SAM3X chip, so should be avoided. As with most Atmel datasheets, actually finding the information you want is almost impossible, and I haven't found if there is a maximum "over voltage input current" or not, so to be on the safe side a full level shifting voltage divider should be used on the RX pin.


Getting the highest value from analog reading?

You don't want to delay ever. Instead you want to change your thinking to "X miliseconds have passed, time to print and reset":

int maxval = 0;
uint32_t lastSample = 0;

void setup() {
    Serial.begin(115200);
}

void loop() {
    if (millis() - lastSample > 100) { // Every 100ms:
        lastSample = millis();
        Serial.println(maxVal);
        maxVal = 0;
    }
    int reading = analogRead(0);
    if (reading > maxVal) {
        maxVal = reading;
    }
}

Every 100ms it will print the maximum analog value read during the past 100ms.

You can replace the 100ms with any other value you choose, or even with a check to see if a button has been pressed, in which case you get the maximum reading since the last time the button was pressed:

// global
bool lastButtonValue = HIGH;

// in loop()
if (digitalRead(3) != lastButtonValue) {
    lastButtonValue = digitalRead(3);
    if (lastButtonValue == LOW) {
        // ... do the print and reset
    }
}


Here are a few things to remember:

You should have a ground connection between the RPi and Arduino
I2C was meant for really short distances on a printed circuit board
Arduino runs at 5 Volt logic levels and RPi at 3.3 Volt logic levels - you need a level translator between them to make that work.

If the RPi and the Arduino are not far apart, I would say less than 1 foot (30 cm) and you have the grounds connected between the boards, then it is a software issue. I2C is meant for short distances any anything longer than a foot puts too much capaitance on the wires and starts causing unreliable communication. I would not even use it for more than a few inches unless it was on a circuit board where you control the capacitance.

I am assuming your using the Wire library on the Arduino side. On the RPi side I would use the the Adafruit I2C library for the RPi as I have had success using the library to communicate with I2C sensors listed on their site. Here is the link:

Adafruit RPi I2C Tutorial


How can I filter out noise from ADC lines without delay or signal change?

The Atmel ATmega328 datasheet, section 24.6.1, recommends that you drive the analog input pin with an output impedance of 10 KOhm or less. Also, it recommends that you remove high-frequency components with a low-pass filter. (That low-pass is sometimes called an antialiasing filter).

The simplest possible low-pass filter is a resistor and a capacitor.

  +5V                        +5V
   |                          |
(sensor)---resistor---+---(Arduino)
   |                  |          |
   |            capacitor        |
   |                  |          |
  GND----------------GND--------GND

Contrary to popular belief, it is not possible to make an antialiasing filter in software.

For an initial low-resolution prototype, a quick rule of thumb is to pick the RC time constant at least 10 times as long as the time between samples.

So if you are sampling at around 1000 Samples/second (i.e., a sampling interval of 1 millisecond), then 100 Ohms of resistance and (roughly) 100 uF ceramic capacitor may be adequate.
(The RC time constant here is RC == 100 Ohms x 100 uF = 10 milliseconds).

Many joysticks already have a relatively high output impedance; you'll need to use a resistor with that much less resistance to compensate.
(Sometimes you don't need any additional resistance; but you still need that capacitor between the Arduino analog input pin and the Arduino ground pin).
(Many sensors have an output impedance more than 10 KOhm; people who use them are pretty much forced to use an op-amp chip to get clean signals).

Entire books have been written on signal filtering.
In addition, there are many other techniques for getting higher resolution analog signals, higher speed data collection, and trading off between them --
but they are probably overkill for reading the position of a joystick.


You can leave them energized for more than 30 minutes. My 16 year old car with 250,000 km still has the original fuel pump relay. I can't imagine how many hours of continuous use it received over this period of time. The relay in my car is not the same make / model as the relays you are using, so you should check with the manufacture to see if there is a "service lifetime" specification.


How to connect a MPU-6050 to an Arduino that already has a CNC Shield V3 on top of it?

MPU6050 can use only I2C. Those are pins A4 and A5 on an Uno. 5V and ground are 5v and ground, no matter from which pin


First of all you need to develop a windows app. You can achieve this by downloading visual studio express for windows desktop from here. Then you must create a project in your language of your preference. You will have to add a serial port component and set the properties to match your arduino serial ones. Then from the event that handles the "data available" of your serial port you can check if there is an incoming character from your arduino and create an if statement that runs the .exe file. Then you must add serial.print('c') to your code when there is a coin inserted. By doing so, you will manage to communicate between arduino and your windows app.

More info and full guide can be found here


How to count the number of button presses then play a sequence?

That's not that complex, please have a look at the following code: not the most elegant solution ever, but should be working (I didn't compile it as I'm currently on launch break in the office)

#define LONGEST_PAUSE 1000
unsigned long lastClick;
unsigned int counter;

void loop() {
  if (digitalRead(buttonPin) == HIGH) {
    // button is pressed
    while(digitalRead(buttonPin) == HIGH)) {
      delay(1); // wait until button released
    }
    lastClick = millis();
    counter++;
  }
  if (counter > 0 && (millis() - lastClick) >= LONGEST_PAUSE) { // 1s passed since last click: let's play!
    switch(counter) {
      case 1:
        s1(); break;
      case 2:
        s2(); break;
      case 3:
        s3(); break;
      case 4:
        s4(); break;
      default:
        // what if I keep clicking?!?
    }
    counter = 0; // reset the counter
  }
}


How to connect capacitive touch sensor to Arduino?

The capacitative touch sensor has 3 pinouts: Vin, GND, and OUT and emits an active high signal when the pad is touched. I should be routing the OUT pin to any one of the digital input pins on my arduino micro, correct?

Probably, yes. Without more details about what the sensor is we can't really comment.

  Also, I need to power 2 of these capacitative touch sensors along with an IMU. How do you power multiple sensors on the arduino micro? There is only one GND pin and one 5 V pin. I would prefer if it could be done without a breadboard as this entire setup will be placed in a stylus.

You can plug as many (within reason) items into the +5V and GND pins as you like. You can twist wires together, use screw terminal blocks, breadboard, solder, whatever you like, to connect the wires together to a single wire that goes to the pin.


Suggest me Arduino device with USB for Mass storage

60 samples per minute, 60 minutes per hour, 24 hours per day, 30 days - that's 2592000 samples. At 10 bytes per sample (a very generous allocation) that's less than 30MB of data.

You could fit that many many times over on even the smallest of today's SD cards, so why mess with the complexity of USB? Any Arduino can work with an SD card.

A bigger concern of yours should not be the storage medium, which is trivial - you should instead be thinking about how you will run the board off a 3V battery for 30 days.


Arduino Uno 3: Stuck at 'uploading...' sketches

You have to wait for the first and all other uploads to fail.

If you are not sure, a reboot is the most reliable solution.

Also note that if your sketch sends a lot of data over serial, a manual reset of the board may be needed.


How to document a custom library in Arduino

Arduino uses the keyword.txt file to highlight words and to define a reference page to keywords. But the reference page must be in reference folder of IDE installation and the keyword.txt contains only a filename, not the path.

  REFERENCE_LINK This field specifies the Arduino Language Reference page to open via Right Click > Find in Reference or Help > Find in Reference when the cursor is on that keyword. Generally it does not make sense to define the REFERENCE_LINK field for 3rd party library keywords since they are not likely to be in the Arduino Language Reference.

I have a library which implements WiFiClient and WiFiServer like the Arduino WiFi library, so I can link in keywords.txt to Arduino reference like this:

WiFiClient  KEYWORD2    WiFiClient
WiFiServer  KEYWORD2    WiFiServer
WiFiUDP     KEYWORD2    WiFiUDPConstructor

The names used are names of html files in Arduino\reference\www.arduino.cc\en\Reference.


Best way to send I2C commands between Arduino and ESP32

First, using a byte-value based protocol is the standard with I2C. There is no real reason to go to ASCII encoded data (The reason for doing this with Serial (UART) is normally, that the message is human readable at the PC. This is normally not the case with I2C, since only computers like the Raspberry Pi even have I2C interfaces).

About delimiters: They are only really needed for asynchronous data transfers (as UART)(to frame a full packet/message) or maybe, if you have an unknown transmission size. Both is not the case for I2C (it is a synchronous interface, that already implements transmission packages/message). You can look at the datasheet of any I2C sensor. The standard communication protocol is a command send by the master, then sending/receiving a specific number of bytes with a specific protocol, that defines, which bytes contains which information. Here you don't need a delimiter, because you already know, in what format the data will be send.

Let's take an example from your question: You want the Arduino to report the speed of your motor to the ESP. You implement the first byte of every master write transmission as a command, for example the decimal value 10 as command to report the motor speed. Then you terminate the master write transmission and request 1 byte from the Arduino (since you already know, that the motor speed has 1 byte). The Arduino knows through the command, that it should send the motor speed byte, and the ESP knows, that the byte received will be the 1 byte motor speed.

Now we define the command 11 to report the motor speed and the 3 bytes sensor value. The ESP sends 11 and then requests 4 bytes, as it knows, that the message will be 4 bytes long. The Arduino sends the data and the ESP knows, that the first byte will be the motor speed and the following 3 bytes the sensor value. No delimiter is needed, since the structure of your data is already defined through the implementation of your protocol. Start or end markers for a message are not needed, since I2C already works with distinct message/packets of data (a transmission is started with a START condition on the bus and ended with a STOP condition).

This solution is used for most I2C devices, since it is easier to implement at a low level. At the first glance for us humans it seems easier to use ASCII encoded and thus human readable data. But as you already mentioned, this makes it more complex for microcontrollers (writing parsers for ASCII data is more complex than using binary data on a fixed protocol). Keep in mind, that I2C means "Inter Integrated Circuit", so communication between integrated circuits, not communication between an integrated circuit and a human.

But in the end it is up to you to decide, which protocol you want to use.

As you might not know the concept yet: A Finite State Machine (FSM) is a good way to implement such a communication protocol on both sides. You define a state variable and based on this variable only the corresponding code is executed. You can change the state by changing the state variable.

For example on the Arduino (receiver side): First state could be the command state, where the Arduino waits for an I2C transmission. If a transmission was received, it will read it's first byte. Depending on this byte it will go into a different state, for example into the "Send motor speed" state. There it will prepare everything to send the motor speed to the master, should the master request data from the Arduino.

How to implement a FSM in detail is covered in many tutorials on the web and also in many questions on this side. You can see my answer to this question, where I explained this in more detail.


How send method POST with JSON? Arduino UNO R3 + SIM900

You had to change the php file:

var_dump($_POST);

to:

echo print_r(json_decode(file_get_contents("php://input")));

Thank you !


ESP8266 wakeup from deep sleep: Both by timer and button?

Place a capacitor on the ESP side of the button to one power rail or the other (my preference is to ground, but either should work), and have the setup() routine reads the state of the pushbutton switch as it's first instruction.  You probably don't even need the capacitor, but if you don't have it, you'll have to read the switch state multiple times to account for possible contact bounce.
If the ESP wakes up due to a timer, there will be no activity on the PB line; if it wakes up due to the PB being pressed, there will be activity on the PB line for several 10's of millisec no matter how quickly it is pressed and released.


Python - Arduino communication not reliable

In case other people run into similar issues, I'll lay out what I've found today.

-The inconsistent output was due to the fact that when you open a serial connection with python, it resets the Arduino and so python can send signals without the arduino having finished its setup() function. If I put in a 1 second delay on the python side, inconsistency stops and I no longer run into byte errors at all. I'm looking into alternative means of preventing this reset since the time delay is a deal-breaker for me.

UPDATE:
Replacing

arduinoSerialData("COM5",9600,timeout=1)

with

arduinoSerialData = serial.Serial()
arduinoSerialData.port = "COM5"
arduinoSerialData.baudrate = 9600
arduinoSerialData.timeout = 1
arduinoSerialData.setDTR(False)
#arduinoSerialData.setRTS(False)
arduinoSerialData.open()

seems to bypass the reset. I included both the setDTR and SetRTS functions here because although setDTR works for DUE, it seems some other Arduino boards need setRTS instead.

-The decode() function has a keyword argument called errors, which can be set to "ignore" if you want the code to just ignore things that can't be interpreted in your desired format. With just this keyword setup, I never got errors but output was inconsistent due to reset.


How can I work with two devices that use the SPI protocol?

If that SD card adapter looks similar like the picture, I never could get it to work together with another SPI device.

What I used was a data logger shield for Arduino (with SD card slot and proto part, unused in my case), something like this: SD logger


Sketch talks to Android via BLE on Serial2 but times out after 5 seconds when Serial cable disconnected or not present

The workaround is to switch to using SoftwareSerial, see code below. Data is continuously sent via Bluetooth from Arduino Mega to Android with or without the usb cable connected.

#include <SoftwareSerial.h>

// Connections
// Arduino HM10
// MEGA
// ----    ----
// 3.3v    VCC
// GND     GND
// 12      RX
// 13      TX

SoftwareSerial bte(12,13);    // RX, TX use (2,3) for UNO
int counter = 0;

void setup() {
  // set the data rate for the SoftwareSerial port
  bte.begin(9600);
  bte.println(counter);
}

void loop() { // run over and over
  bte.println(counter);
  counter++;
  delay(1000);
}


Possibilities and limitations for onboard data acquisition

First of all your idea project is feasible. And to answer to your questions:

There is no right Arduino for your project simply because theoretically every Arduino board can do the job. But as you said it has to be portable you might use Arduino nano/mini or even Uno if you have enough room or space.
The acquisition rate depends on the on the type of sensor you have. So if you have let's say one analog reading you can use the built in function in Arduino which is capable of making about 10000 readings at time. So if you have multiple outs you can easily for the calculation. There are also sensors which has a digital output in this case in order to read your value you communicate with Tue sensor board through Two wire interface or I2C communication interface, for this there is a library you can use. Usually the speed at which this communication work s very high, at 100kHz( if I'm not wrong).

3.Yes you can save data on the SD card until you don't exceed the memory or the battery doesn't die.

I have a suggestion for your project, as you're going to acquire some sort of data and then analyze it on your computer, do less calculations on your Arduino board and let the PC handle the hard work.

Useful links:

Reference to the two wire communication: http://arduino.cc/en/reference/wire
Reference to the SD card reading on Arduino: http://arduino.cc/en/Reference/SD


ESP8266 SoftwareSerial not receiving any character

If the ESP8266's software serial is anything like the Arduino's software serial, it cannot receive data while it's transmitting. It's strictly half-duplex.

To test your system you will need to test the transmission and reception completely separately, and that means having some external device sending data for you to attempt to receive.


If you have a bootloader, you just need to connect up four wires from the FTDI cable:

Pin 1 (black) -> Ground
Pin 2 (CTS)   -> not connected
Pin 3 (Vcc)   -> 5V
Pin 4 (TxD)   -> Rx (Mega pin D0)
Pin 5 (RxD) -> Tx (Mega pin D1)
Pin 6 (green) -> not connected

This will not auto-reset, so you will have to press (and release) the Reset button on the board at the moment that the sketch starts to upload.

  How to make it auto reset?

What you should be able to do is connect RTS to Reset on the board, using a 0.1 µF capacitor (in series). I found in practice that this did not bring Reset low enough to trigger it - I'm not sure why, except maybe the board has a stronger pull-up resistor on /RESET than expected. That technique works for me on breadboard Arduinos.

Since it didn't work for me, I did not put it in my original answer. You could try that, and if it works, well and good.


You are correct, random() isn't random - it's pseudo random. It returns successive results from a mathematical formula which, to all intents and purposes, is random. It's also predictable, as you have seen.
The formula has a starting value, called the seed, which you can choose your self. Changing that seed gives you a different sequence of random-like numbers.
So the trick is to set the seed to something that is truly random. One common source of randomness, or entropy, is an unconnected ADC input:
randomSeed(analogRead(A3));

You can read more about the randomSeed() function here.


Arduino Wifi Works one way but not the other? (ESP32) (Possible Variable Type Problem)

Basic string in C is an array of characters terminated by a 0. All functions taking char* or const char* use this 0 to determine the end of the string, because there is no other information about the length of that string.

In your question you copy characters from one characters buffer to other, but you do not set the terminating 0, so the function begin takes the data after the pass pointer until some random memory location with 0.


Forwarding serial output from a Nano to Uno that's used as the ISP

As Chris Stratton suggests in his comment above:

  You can't really connect an ordinary Arduino's serial pins to both another device and the on-board USB serial converter at the same time.

To solve your serial monitor problem use a separate USB serial converter and connect that to your Arduino Nano.

If you don't have access to a dedicated USB serial converter you could use software serial on the Arduino Nano. This allows you to connect the Arduino Uno Rx pin to the software serial Tx pin. You will also need to program the Arduino Uno with a program that re-transmits the data it receives back out to the PC serial monitor.


Why can't my Arduino IDE recognize serial ports? (Mac El Cap, Ard. UNO)

"ATmega16u2 DFU" indicates a USB interface micro that is in a state to have new firmware downloaded to it (DFU), not one which is ready for operational use as a USB interface to program the Uno's ATmega328p target MCU.  If this persists after power-cycling/re-plugging the board, it is probably faulty and at minimum needs firmware repair - though it might be worth trying on another computer (preferably with a different OS or version) just to be absolutely sure nothing in the host software is forcing it to this mode.

If this is a new board you have not modified in any way, you should probably return it as defective.

If you have modified it, or you want to try to fix things yourself, you would need to follow the instructions for reflashing the 16u2 via USB-DFU.  Beware that this is a non-trivial task that looks like it is going to require installing macports and running some terminal commands, and on older boards some soldering.


Does delay() pause the counting of millis()?

Delay uses millis. It just waits examining millis until a certain time has passed.

Millis is driven by an interrupt. The only thing that stops it working is another interrupt (you can only have one interrupt executing at once), which is why you can't use delay in an interrupt.


ESP8266 Webserver ESP8266WebServer variable html page (not as one const char)

Compiler can't differentiate the PROGMEM strings from constant strings in SRAM strings. Both are const char*. But the PROGMEM string must be handled differently. For that reason _P variants of functions exists.

You should use stcpy_P and strcat_P functions.

Note: On esp8266 some functions of Arduino core use a trick to identify PROGMEM strings by their specific address range.


When you declare int array[50]; you declare an array of numbers so only numbers can be stored inside it. If you really want an array of strings then declare an array of strings like String array[50]; There was also a a problem that sometime you split the name by comma, sometime by space, and sometime by comma+space. Also your code was missing closing bracket.
The algorithm has to split both by comma and my space and then take only values that have length more than one to avoid inserting empty strings.
String name = "s111, s222, bbbb,cccc ";
String array[50];
int r=0,t=0;

for(int i=0;i<name.length();i++)
{
  if(name[i] == ' ' || name[i] == ',')
  {
    if (i-r > 1)
    {
      array[t] = name.substring(r,i);
      t++;
    }
    r = (i+1);
  }
}

for(int k=0 ;k<=t ;k++)
{
  Serial.println(array[k]);
}


How to HTTP post a data to Node express API from a Arduino esp8226?

Did it heres the code

`if (client.connectSSL(server, 443)) {
Serial.println("Connected to server");
// Make a HTTP request
String PostData = content + volt;
Serial.println(PostData);
client.println("POST /api/users HTTP/1.1");
client.println("Host: morning-cliffs-85779.herokuapp.com");
client.println("Cache-Control: no-cache");
client.println("Content-Type: application/x-www-form-urlencoded");
client.print("Content-Length: ");
client.println(PostData.length());
client.println();
client.println(PostData);
}`

Hope it helps some one


Using Arrays and LED's to represent Piano Scales

Your current code will not show all notes of a scale. Only the notes at 1 and 2 will light up, since you don't sum up the numbers, that you have stored in MajorScale. But I think it is not a great idea to sum them up programatically, since this is a constant and you don't win much by representing the data this way. Instead you should directly initiate the MajorScale variable with the summed up values:

int MajorScale[] = {0, 2, 4, 5, 7, 9, 11};

Then you can enclose your for loop with another for loop, that adds an offset corresponding to the octave:

for(int j=0; j<NUM_LEDS; j+=12){
    for(int i=0; i<=6 && MajorScale[i]+j<NUM_LEDS;i++){
        leds[8+MajorScale[i]+j] = CRGB::BlueViolet;
        FastLED.show();
        delay(delayvalue);
    }
}

So we set the LED number 8+MajorScale[i]+j. 8 for the offset to C, MajorScale[i] as the position of the note in the current octave and j for the offset of the current octave relative to the C.

Note, that this is not tested in any way.


Here is an analogy for you to help you understand why using the IRQ is a good idea.

Imagine you are at a conference. There's hundreds of you in the audience, and you are in a question and answer session with the person on the stage. Maybe their presentation has just come to the end and they're fielding questions from the audience.

Lots of people have questions, and any member of the audience can raise their hand at any time to ask a question.

Now there's three ways of the presenter handling it.

The first way is your way of using an interrupt and responding to the interrupt within the interrupt handler itself.  This is like the presenter stopping what he is saying mid sentence to answer the new question. That's just nasty, and both confusing for the presenter and the audience.

The second way is for the presenter to continue until the current question has finished being answered, then pick someone at random from the sea of hands. While the question is being answered people are getting antsy waving their hands around to get noticed, and there's no guarantee that it will be first come first served. People may then not be paying attention to what is a good answer to an important question because they are fixated on theirs.  That's just the same as you polling the interrupt line, or polling the screen directly. If the interrupt line isn't active at the time you poll it you'll miss it.

The third, and best way, is if the presenter sees a hand go up while he's answering a question, and acknowledges that person with an "Ok, I'll come to you next.". Everyone else knows that waving their hand around is pointless, so don't bother - and the next question can be asked immediately after the current question has been answered. Everyone is happy.  That's the proper way of handling a system like this - when the interrupt triggers you remember "Ok, I'll come to that interrupt signal in a moment when I'm ready". Then in your loop, when you have the time, you act on the interrupt that you remembered earlier. You get to respond at your speed to a signal that you may otherwise have missed.

So to sum up: using an interrupt to remember that something is pending and then act on that remembered state is how you should use interrupts to manage communication.


Yeah... sometimes it's easier to scrap what's already there and start fresh.

We need to:

Pick a suitable prescaler to get close to the desired cycle length
Fine-tune the value in TOP in order to get an exact value

Assuming this is a 16MHz Leonardo, and we have Fast 10-bit PWM (PWM4x = 1, WGM4x = 0b00) available:

16MHz / 50Hz / (1 << 10) = 312.5

Therefore we need a prescaler of 512 (CS4x = 0b1010).

16MHz / 50Hz / 512 = 625

Therefore we need a TOP of 624 (OCR4C = 624).

TCCR4B &= ~(_BV(CS43) | _BV(CS42) | _BV(CS41) | _BV(CS40));
TCCR4B |= _BV(CS43) | _BV(CS41);
TCCR4D &= ~(_BV(WGM41) | _BV(WGM40));
TC4H = 624 >> 8;
OCR4C = 624 & 0xff;

And then you set COM4xn and PWM4x to appropriate values for whichever pin(s) you want to output PWM on, and set OCR4x to a value between 0 and 624 (using TC4H appropriately; see the datasheet for details) to control the duty cycle.


The issue is that Arduino boards (8 bit ones at least), an int is 16 bits, where as the ESP's (8266 and 32) and possibly other non-arduino hardware, an int is 32bits

The safest way to declare structs in any case is to use variable types with known sizes, in your case, for signed 16bit ints

struct data {
  int16_t id;
  int16_t pin;
  int16_t value1;
  int16_t value2;
} myData;

or for unsigned 16bit ints

struct data {
  uint16_t id;
  uint16_t pin;
  uint16_t value1;
  uint16_t value2;
} myData;

Note: there's also short int which I believe is "guaranteed" to be 16bit (and "long int" is always 32 bit) - but having the bit size in the declaration is a far better (future proof) solution


how to know which pin is being used, change pin?

Your confusion is over the multiple functions of analog pins A4 and A5.

In addition to being analog pins, they are also the pins configured internally for I2C/TWI serial, which is interfaced with using the Wire library on arduino. Since those are the only two pins Wire can use, there is no need to specify them, the sketch just calls Wire.begin() to set everything up.

If you need a second I2C device you can simply connect them both up to A4 and A5 at the same time, the protocol is designed to support that kind of thing. If you need to use A4 and A5 for something else besides I2C, you can't continue to use the hardware I2C library.

It is possible to use a software implementation of I2C/TWI serial on other pins, but usually soft-serial implementation have some drawbacks compared to the hardware version. There is an implementation on the arduino playground here: http://playground.arduino.cc/Main/SoftwareI2CLibrary

That said, the RTC library you are using seems to internally use the Wire library, so it would take some hacking to switch it to a different I2C implementation.


Arduinos using I2C reading integers wrong

wire.write(n) sends a single byte of value n

150 decimal = 96 Hex
300 decimal = 012C Hex ...so is 2 bytes, and is truncated to one byte of value 2C Hex.

2C Hex = 44 decimal

Send a single byte! Maximum value of a byte is 255 decimal

If you need to send multiple Len bytes, then you need to ascertain the number of bytes and send them individually.
In your code you send multiple bytes concatenated one after the other already ...you send Pitch followed by Len.
All you need to do is split Len into L1, L2 bytes first.

L1 = Len and xFF
Shift Len left or do other logical math to derive high byte, L2
Then send L1 and L2


How to use this Arduino code to control multiple different LEDs?

Its better if you use SoftwareSerial for Bluetooth, so the native serial port can be used to debugging. But in case you doesn't need them:

uint8_t led[4] = {5,6,7,8}; // pin for LED 1,2,3,4
char command1,command2;
String string;
  void setup()
  {
    Serial.begin(9600);
    for (int i=0; i<4; i++)
        pinMode(led[i], OUTPUT); //set all LED pin as OUTPUT
  }

  void loop()
  {
    if (Serial.available() > 1) //run if 1 bit or more data received
    {
    string = "";
        command1 = Serial.read();
        command2 = Serial.read();
        switchled(command1-'0',command2-'0');
    string = command1+command2;
    }
    delay(1);
  }
void switchled(char pinLED,char statusLED)
{
    if (statusLED == 0 || statusLED == 1)
    digitalWrite(led[pinLED-1],statusLED);
    else
    digitalWrite(led[pinLED-1],!digitalRead(led[pinLED-1]));

    Serial.print("LED ");
    Serial.print(pinLED);
    Serial.print(" = ");
    Serial.print(digitalRead(pinLED));
}

The code reads 2 byte of data, so if your phone sent "11" the 1st led will turned on, and "10" will turn the 1st led off. The first digit is the LED index (1/2/3/4) and the second digit is the LED state (0/1), other than that, the LED on selected index will be toggled;


(SOLVED) Fast HW check: (18 digital + 4 analog to I2C ) Arduino Mini Pro + MCP23017 or STM32?

Can mentioned STM be easilly programed as Arduino, manage I2C communication, and still have comfortable 18+4 I/O pins free? And 23+4 I/O free?

it can be programed as Arduino, manage I2C communication, and still have 18+4 I/O pins free or 23+4 I/O free.

it is only knowable to the person programming it whether it can be done easily or comfortably.


Looking to optimize this code and add a loop

You could use a for loop so you don't need to repeat the yellow blinking led code 7 times.
To keep the red leds alternating, you use a while loop.
int switchState = 0;
int green = 3;
int yellow = 4;
int red1 = 5;
int red2 = 6;
int button = 2;

void setup()
{
  pinMode(green, OUTPUT) ;
  pinMode(yellow, OUTPUT) ;
  pinMode(red1, OUTPUT) ;
  pinMode(red2, OUTPUT) ;
  pinMode(button, INPUT) ;
}

void loop()

{ //start void loop 1
  switchState = digitalRead(button);

  if (switchState == LOW)         //button not pressed
  {
    digitalWrite(green, HIGH);      //green LED on
    digitalWrite(yellow, LOW);
    digitalWrite(red1, LOW);
    digitalWrite(red2, LOW);

    delay(500);

    digitalWrite(green, LOW);     //blink green LED

    delay(500);
  }//end if

  else        //Button pressed
  {

    digitalWrite(green, LOW);
    digitalWrite(red1, LOW);
    digitalWrite(red2, LOW);

    //Blink yellow LED for 3 sec
    for (byte i=0; i<7; i++)
    {
      digitalWrite(yellow, HIGH);
      delay(250);
      digitalWrite(yellow, LOW);
      delay(250);
    }

    // alternate the two red leds, while the button is pressed
    while (digitalRead(button) == HIGH)
    {
      digitalWrite(red1, HIGH);
      digitalWrite(red2, LOW);
      delay(250);

      digitalWrite(red1, LOW);
      digitalWrite(red2, HIGH);
      delay(250);

    }     //end while loop

  }     //end button press

}     //end void loop


Sending JSON message to web api via post. Why does HTTP 1.0 versus 1.1 make a difference?

HTTP/1.1 requires you to provide the host name of the server. And it will keep the connection open for some time unless you explicitly opt out of this. Thus, the equivalent of the basic HTTP/1.0 request in HTTP/1.1 language is

POST /the_uri HTTP/1.1
Host: foo.example.com
Connection: close


ATMEGA 328P Standalone on 3.3v controlling a servo

do I have to convert the PWM signal's peak amplitude to 5V for it to work?

There is insufficient information to determine that.  It may, or it may not. You'll have to try it and see.

  since I will be using an 8 MHz external clock, do I have to change anything in my Arduino sketch regarding the PWM signal frequency

If the board you select is 8MHz then no, you don't need to change anything. The fact you have selected the right frequency for the board means that all the timing calculations the Arduino API does will be correct.


A class that uses <...> is called a template class.  That class uses a form of substitution at compile time to create a concrete class with those values and tokens substituted.

It is then that concrete class that is used to instantiate your object(s).

However, you are trying to use a runtime variable to convert a template class into a concrete class, and that can't be done at compile time - and there is no such thing as a runtime template in C++.

You need to re-think your implementation methodology.


Does the Node MCU v3 (LoLin) not have a builtin led?

the ESP8266 has a builtin led that is attached to D4 as labeled on LoLin boards which maps to GPIO2. One thing to Note is that the led is active low. In other words ... setting PIN 2 to '0' will turn the LED ON and setting PIN 2 to '1' will turn the LED OFF

Lolin Builtin_Led Picture

This is the only LED on the LoLin boards and differs from other devkits that have an LED on GPIO16.


How do I transform data for a column to data for a row, for a led matrix

You use a mask 10000000. With each iteration of the outer loop the 1 in the mask is shifted to the right. 01000000 -> 00100000 -> 00010000. Let's say we are in the 2nd iteration the mask is 01000000. x = x | (valueVector[p] & mask); takes the 2nd bit (counted from left) and sets it at the 2nd position in the x value. But this position contains the bit from the last iteration (as you shifted it to this position).
Possible solution: (I have no compiler at hand. So hopefully it is correct. ;-)
byte x;

for ( int j=0; j<8; j++ )
{
   x = 0;

   for ( int p=0; p<8; p++ )
     x = x | ((valueVector[p] & (1 << p)) >> p);

   lc.setRow(0, j, x);
}


The device ID and every other stuff is working fine. The only issue being that my code gets stuck at Wire.endTransmission().

Nothing is transmitted until you call Wire.endTransmission() so that is where it will hang.

You should not try to do Wire transmissions inside an ISR (if you are doing that).

There is an alternative to the Wire library which times-out rather than hanging. It is at: Arduino I2C Master Library.

Make sure you have pull-up resistors on SDA and SCL. Typically 4.7 k from both to +5 V.

If none of that helps, please post your code.


Can I use L293D driver as ESC for arduino controlled quadcopter

Bipolar bridge drivers like the L293D, L298, etc have extremely high losses.  They are long out of date and a poor choice compared to modern FET chips even for surface vehicles, let alone something that needs a good power to weight ratio for flight.  Typically if you made a small robot with one and some AA cells, you'd have to have an extra cell in the pack just to cover the losses of the L293D.  An aircraft (and especially a vertical lift one) cannot afford that waste.  Also the wasted energy shows up as heat (though I suppose you could position the chip in the propwash).

Actual quadcopters use MOSFET drivers, typically discrete ones carefully selected for a low RDSon at a low enough threshold voltage to fully turn on when driven by an MCU output.  Either just one N FET per motor for unidirectional control of brushed motors, or H bridges made of an N FET and either a P FET or else an N FETs with special high side driver circuitry for bidirectional control of brushed motors, or similarly as a half-bridge for each of the three leads of a brushless motor.  The MOSFETs may be found either on the main board in a single board quadcopter, or else they may be packaged in modular speed controllers separated from it.

But providing current to drive the motors is the easy part - sequencing brushless motor commutation, and stabilizing a flight platform are the hard parts.

In that regard, an Arduino is a very poor choice as a flight controller.  A literal one means carrying around a lot of extra mass and connectors that aren't really fitting.  A work-alike on a custom board is possible, but most of the open source projects that started that way have long since moved on to other MCUs with more capability.  You do still see ATmega8's within brushless motor drivers though.


Transmitting multiple values to the arduino, and Interpreting them with minimum delay

I don't know about commercial drones, however your 'protocol' seems to be quite efficient, as it uses 4 bytes to send 2 values (e.g. U3F5) for Up with speed 3 and Forward with speed 5.
Let's assume values from 0-7. Then you can send them both in 8 bits/one byte:
H H H H V V V V
Where H is the horizontal speed (from -8 (000) to +7 (111), in total 16 possible values.
For the vertical speed you can do the same.
So within one byte you send both speeds (meaning also there is no lag).
In case you need more accuracy, than send two bytes: one byte with horizontal and one byte with vertical speed. Depending on the sending/receiving speed I doubt there is any lag.
Even with your protocol I doubt there is a lag, but the above is more efficient.
I'm sure even more efficient algorithms can be created, probably by using the difference with the previous value (like sending delta values).
Another algorithm that can be created, assuming there is a big chance that only one of the two directions is changed (either horizontal or vertical is) and having a high accuracy
D V V V V V V V

Where D is the direction (0 = horizontal, 1 = vertical) and V is the value/speed (-64 to +63, 7 remaining bits).


How can I light one led from two different sensors?

int ledPin = 13;

int ldrPin = A0;

int PIR_Pin = 2;

void setup()

{

    Serial.begin(115200);

    pinMode(ledPin, OUTPUT);

    pinMode(PIR_Pin, INPUT);

    Serial.println("Started Monitoring!");
}

void loop()
{

    boolean lightStatus = ( analogRead(ldrPin) <= 400 ) ;
    digitalWrite(ledPin,  lightStatus);

    if(lightStatus) Serial.println("Light Triggered!");

    if(digitalRead(PIR_Pin) == LOW)
    {
         Serial.println("Motion Triggered!");
         digitalWrite(ledPin, HIGH);
         delay(5000);
         digitalWrite(ledPin, LOW);
     }
}

To keep it simple serial code is removed, if needed can be added easily that should not be a big issue.
Still this can be done in much more efficient way. This is just one solution.

Note: haven't complied/error checked the code as i am writing this on a phone. Hope it should work as intended, errors if any, shall be minor ones.  Comment below if any issues.

Update 1: added code to send triggered status over serial comm.

Update 2: corrected "Boolean" to be as "boolean"


An int can't hold 1000000.  It is a signed 16-bit variable, which means it can only hold between -32768 and +32767.

To store larger numbers you need to use long, or unsigned long which are signed and unsigned 32-bit variables.


Two Identical Potentiometers, two different results

Trimmers have a really low current rating, so if you hadn't protect it enough, maybe you have broken it. Always remember a pull up resistor of 10k or more.


Beat 1 LED light is always on - should turn off

You are using PIN1 as an output pin and you are writing data to the Serial interface.  The serial interface uses pin 1 and 0.
Change lowestPin to 2 and ts to 5 and it will work.


Can't write to serial immediately from PC to Arduino nano via pl2303 usb to ttl converter

I have experienced similar behavior with clone chips. What worked for me is using ferrite choked USB cables similar to these; as you referenced as well, I observed that the problem occurs with either longer cable, or with cables without ferrite chokes on them. This might have to do with the PCB or the cheap chips being prone to electromagnetic interference.


The photo of your circuit doesn't really show, how all the components are wired. For this you should either draw a schematic (which you can do with the schematic tool directly in the question editor) or provide a good visible wiring diagram like from Fritzing (though a proper schematic would be better).

For now I cannot see any wrong wiring, though you definitely should recheck it and add a proper diagram to your question.

For your code I will shortly sketch the functionality of non-blocking code and a state machine:

Non-blocking code: Task, that require a long amount of time (this means long for a microcontoller; seconds are long in this context), you should not use code, which blocks the whole program execution, until the task is completed. Instead you should only shortly check, if there is an action to be taken. If not, quickly proceed with other code. This enables you to do, which seems to be multitasking. For timed sequences you can use the millis() function. It returns the number of milliseconds since the program has started and overflows after 50 days. The following code saves the timestamp, when the LED was toggled the last time and checks, if enough milliseconds have passed since the last time. This way you can do something else in the meantime (like checking the state of your sensors). Also refer to the BlinkWithoutDelay example of the Arduino IDE.

unsigned long timestamp = 0;
unsigned long interval = 500;
...
void loop(){
  if(millis() - timestamp > interval){
    digitalWrite(led_pin, !digitalRead(led_pin));
    timestamp = millis();
  }
}

State machine: A state machine is code, that holds it's current state in a variable, thats mostly numeric. This variable is read at every loop cycle and used to determine, which piece of code is to be executed. In your case you would have states for "red light on", "yellow light on", "green light on", "distance lower than 10cm" and "LDR reports low light condition". Each on this gets it's own number. For convenience you should use an enum. Now on every loop cycle we use a switch case to go to the right code depending on the state. For your case you would set the state code with non-blocking behavior as described above. Then you only need transitions between the states, by setting the state variable.

enum STATE {STATE1, STATE2, STATE3};
STATE state = STATE1;
...
void loop(){
  switch(state){
    case STATE1:
      digitalWrite(led1_pin, HIGH);
      if(millis() - timestamp > interval){
        digitalWrite(led1_pin, LOW);
        state = STATE2;
      }
      break;
    case STATE2:
      // doing whatever this state needs to do and then do transition with setting state variable
      break;
    case STATE3:
      // doing whatever this state needs to do and then do transition with setting state variable
  }
}

For designing the states and transitions it sometimes makes sense to sketch them on paper. A bubble with a names is a state and then you connect these states with arrows.

Since you want to check the sensors in every state, you should do this outside of the switch statement. The measurement functions then do nothing else but the measurement and setting the state variable accordingly (so no digitalWrite() or delay() in there).


How can I send and receive data from an Arduino Uno to Arduino Mega using I2C?

At instructables there is a good post.

In short the code is

Master code:

// Include the required Wire library for I2C
#include <Wire.h>
int x = 0;
void setup() {
  // Start the I2C Bus as Master
  Wire.begin();
}
void loop() {
  Wire.beginTransmission(9); // transmit to device #9
  Wire.write(x);              // sends x
  Wire.endTransmission();    // stop transmitting
  x++; // Increment x
  if (x > 5) x = 0; // `reset x once it gets 6
  delay(500);
}

Slave code

// Include the required Wire library for I2C
#include <Wire.h>
int LED = 13;
int x = 0;
void setup() {
  // Define the LED pin as Output
  pinMode (LED, OUTPUT);
  // Start the I2C Bus as Slave on address 9
  Wire.begin(9);
  // Attach a function to trigger when something is received.
  Wire.onReceive(receiveEvent);
}
void receiveEvent(int bytes) {
  x = Wire.read();    // read one character from the I2C
}
void loop() {
  //If value received is 0 blink LED for 200 ms
  if (x == '0') {
    digitalWrite(LED, HIGH);
    delay(200);
    digitalWrite(LED, LOW);
    delay(200);
  }
  //If value received is 3 blink LED for 400 ms
  if (x == '3') {
    digitalWrite(LED, HIGH);
    delay(400);
    digitalWrite(LED, LOW);
    delay(400);
  }
}

In the instructables post a lot more explanation is shown.


Using an Arduino for a Diorama Controller

First, since you didn't mention any kind of Arduino, my answer is based on using Arduino Uno/Nano (I think its the most common)
 1. Yes you can. You use 1 transistor per building as switch (if there are many LEDs in the building) to gives optimal current and prevent your Arduino pin. The value of R2 -- Rx is depend the LED colour. You can control each group with one Arduino pin.

simulate this circuit – Schematic created using CircuitLab

Yes you can, one in my mind is using PWM feature, like this project
Yes you can. But maybe the generated sound is not up to your expectation. Here is one of the simple example and this maybe a bit challenging.
The battery is up to your setup. More output (such as led and speaker) requires power source that can provide greater current. Arduino Uno voltage limit is 6v-20v
In my opinion, yes.

As for the form factor, I think Arduino Nano is small enough to hide in the building, while Arduino Uno size is just slightly less than a Raspberry Pi.

Good luck for your project :)


Two-way communication on multimaster I2C bus

notice missing transfers to the masters when more than one master is active.

Because you didn't provide a way for the master's to know of a transmission ISS in progress. Lack of conflict resolution. A problem with all multimeter transmission.

A simpler approach is for the slave to signal a transmission from the master. That can be done via a slave requestion pin from the slave to the master.


Try out this schematic. It will work.

So code will be :

int red = 8;
int uv = 9;
int redbutton = 2;
int uvbutton = 3;
int redbutcondition = 0;
int uvbutcondition = 0;

void setup()
{
  pinMode (red, OUTPUT);
  pinMode (uv, OUTPUT);
  pinMode (redbutton, INPUT_PULLUP);
  pinMode (uvbutton, INPUT_PULLUP);
}

void loop()
{
  redbutcondition = digitalRead(redbutton);
  uvbutcondition = digitalRead(uvbutton);

  if (redbutcondition == LOW)
  {
    digitalWrite(red, HIGH);
    digitalWrite(uv, LOW);
  }
  else if(uvbutcondition == LOW)
  {
    digitalWrite(uv, HIGH);
    digitalWrite(red, LOW);
  }
}


Setting an array pointer to null on declaration

Here is a full example that shows you all thing things you have been asking over the past few days:

int colors[][3] = {
    {255, 0, 0},
    {0, 255, 0},
    {0, 0, 255}
};

#define NCOLOR (sizeof(colors) / sizeof(colors[0]))

int *EXCLUSIVE_COLOR = NULL;

void setup() {
    Serial.begin(115200);
    Serial.print("You have ");
    Serial.print(NCOLOR);
    Serial.println(" colors defined.");
    reportColor();
    EXCLUSIVE_COLOR = colors[2];
    reportColor();
    EXCLUSIVE_COLOR = NULL;
    reportColor();
}

void loop() {

}

void reportColor() {
    if (!EXCLUSIVE_COLOR) {
        Serial.println("Color is not set");
    } else {
        Serial.print("Color is set to ");
        Serial.print(EXCLUSIVE_COLOR[0]);
        Serial.print(",");
        Serial.print(EXCLUSIVE_COLOR[1]);
        Serial.print(",");
        Serial.println(EXCLUSIVE_COLOR[2]);
    }
}

You have an array of colours. You have a pointer that can point at a colour or at nothing. It starts off pointing at nothing. The code recognises that it's pointing at nothing and reports it. It gets assigned to a specific colour in your colours array. The code recognises that it's now a valid value and reports it. The pointer then gets pointed to nothing again. Again the code recognises that and tells you.

The result:

You have 3 colors defined.
Color is not set
Color is set to 0,0,255
Color is not set


Increment in switch statement not working

Looks to me like the path where the if doesn't happen are getting you. You don't show what DBNC_TICS is set to, but I'm assuming it's > 1.

ptrButton->debounceTics will never be greater than 1 because you always:

    ptrButton->debounceTics = 0;


Converting uint8_t to String - unexpected result

You should convert your number uint8_t into it's ASCII representation before appending it to your string, otherwise you are appending just one character using it's byte representation.

To do so you can use a standard function itoa() which has a decent documentation available here.

So change line

 String Sync = "PaletteBrightness:" + PaletteBrightness;

into

 char buffer [4];
 String Sync = "PaletteBrightness:" + itoa(PaletteBrightness, buffer, 10);


Accelerometer Interrupt Meaning - Wakeup Function

The INT_GEN_CFG_XL 6-Direction detection interrupt apparently is aimed at detecting change of direction of travel, rather than an axis-combined acceleration level.

See the LSM303 discussion at Polulu.com.  That page includes a link to App Note CD00290365.pdf for the LIS3DH.  Here is what that app note says, on page 27:

  There are two possible configurations for the 6D direction function:

    • 6D movement recognition: In this configuration the interrupt is generated when the device moves from a direction (known or unknown) to a different known direction. ...
    •  6D position recognition: In this configuration the interrupt is generated when the device is stable in a known direction. ...

With the LSM9DS1 that you are using, you can leave OR enabled, set separate X,Y,Z threshholds in INT_GEN_THS_X_XL, INT_GEN_THS_Y_XL, INT_GEN_THS_Z_XL, and set the “Enable interrupt generation on accelerometer's X axis high event” (sim. for Y and Z) bits in the INT_GEN_CFG_XL register.


I'd probably do it directly like:

for(int i = 0; i<6;  i++) {
  BTLEserial.print(items[i]);
  BTLEserial.print(',');
}
BTLEserial.println();

But with the string I think it would be something like:

String output = "";

for(int i = 0; i<6;  i++) {
  output += getStringForUI32_T(items[i]);
  output+=",";
}
BTLEserial.println(output[0]);

But as someone else got it working using String on your adafruit thread maybe this is just barking up the wrong tree.


Connecting multiple component's VCC wires to one Arduino UNO R3 5V Pin

Assuming you have suitable soldering skill, there are some considerations when you solder lots of wires to one header:

Lots of wires means lots of weight. The strain of several wires may degrade your connection or header over time, especially for a wearable system, where I assume the parts would be subject to some movement.
The width of the connection when all the wires are soldered to it. It might touch adjacent pins, or lean on them, creating mechanical stress. Heatshrink or sleeving can help with the electrical contact issue, but won't remove the mechanical risk.
Lots of wires soldered to one point may make the system more difficult to service. Instead of desoldering the wire to one component, you have to either desolder them all, or cut the wire to the one suspect component and then solder together wire stubs later to replace it.

When referring specifically to power supply pins, you'll need to consider the peak current requirements of anything you power from it. Based on https://playground.arduino.cc/Main/ArduinoPinCurrentLimitations it seems like you shouldn't be pulling more than 200mA from the Vcc PIN. Check the maximum current draw of all of your components that you want to power, add them together, and make sure it's under the limit of the Arduino board.


Using SCL and SDA of ESP8266-01 with GY-30 BH1750FVI for lux measurement

Wire is not setup for the ESP01 by default. There is no GPIO 4 or 5. you can specify the pins as arguments to the begin() method, ex: Wire.begin(sda, scl). Using GPIO of (0,2) is common. Since the ESP01 is picky about pin states during power-up, don't use external pullups (you don't need them anyway).


technically yes, there is no reason you can't do that project but the issues will come in how complex you wish to make system. For example, it shouldn't be too hard to hook up the three sensors to three analogue Pins on the Arduino and then have the Arduino constantly loop to check the voltage of the sensors, from which, you would tell it to 'do something' when one of the IR sensors voltage is above or below a certain value. What you then choose to do is up to you, if it's just to turn on a light then it can be done fairly quickly once you have all the components. For controlling the Audio in the file, I personally have no experience with this.
What might be better is first checking to see if you can Adjust the audio in one of your files using an Arduino (you may need to use bluetooth or have something on your PC communicate with your Arduino via UART through the USB).
Generally, with new projects, it's a good idea to figure out a solid plan for exactly what you want to do, so I would write down in detail what you want the system to do and then go through each part to see if it's possible


How can i do something like multi threathing in arduino?

You will not have full parallel execution in an Arduino (only one CPU).

You might do multi-threading by implementing a small OS (e.g. FreeRTOS)
Or write your own task scheduler.
Or even just do state machine looping forever checking if push or pop has to be executed.
Last and preferred solution: I would consider running the normal Push task always and execute the Pop task (function in fact) using interrupts.


How to execute operation once till a condition then restart it from start

My suggestion is, even if it seems to be a simple example, to start with an analysis of what you really want to achieve. In this example I would try to start with an state diagramm. With this you could clarify simple questions, e.g. what happens if the IR goes low while the motor is turning. In my draft, the motor would keep running, but maybe the IR is for safety reason and you want to stop motor if something approaches. If that is your intention, you can easy add aditional transitions at all states to return to state 00.

Such an approach helps you in creating code easy to maintain and change to new requirements

After having your state diagramm finished it is often easy to start programming with switch/case sturctures for first learning experiences.

Switch(state) {
  case 00:
  // if IR set state = 10;
  break;
  case 10:
  // if button was pressed set state = 11
  break;
  case 11:
  // turn motor
  // if treshold set state = 12
  break;
.
.
.

}


Simplest way to do this is two MOSFETs (one per motor, because you don't need to change direction), and some miscellaneous passives, and a flyback diode for each motor.

See this tutorial for wiring diagrams and details.


My EthernetENC library based on the original UIPEthernet library by Norbert Truchsess has settings to balance performance and memory usage. These settings are in utility/uipethernet-conf.h file or can be specified as -D parameters for compilation.
UIP_CONF_MAX_CONNECTIONS is a maximum number of connected EthernetClient connections. The default value s 4. You can set it to 0 if you don't use EthernetClient TCp connections. It will save a lot of dynamic memory.
Arduino IDE doesn't have the possibility to set defines for a sketch (For example Sloeber has it). As some workaround to set the defines for different boards for Arduino IDE, you can create a file boards.local.txt next to boards.txt file in hardware package. Set build.extra_flags for individual boards.
comment by OP:

Setting uno.build.extra_flags= -DUIP_CONF_MAX_CONNECTIONS=0 in "boards.txt" in the arduino IDE folder reduced program memory usage by 2442 bytes and dynamic memory usage by 290 bytes.


Your current problem is that the USB Serial interface of the Leonardo isn't a hardware serial device, it's a CDC/ACM device, and the class for that isn't HardwareSerial, it's Serial_.

So you can't pass it to a function that expects a HardwareSerial.

What you should be using, instead, is the Stream class.  That will allow you to pass any object that is based on the Stream class, such as HardwareSerial, Serial_, Client, etc.  Many different things, including serial and networking protocols, use Stream as their base class.

It does have the down side, though, that you have to initialize the Stream objects in your sketch (that is, do the Serial.begin(...) and Serial1.begin(...) in your sketch not your class) because the Stream class doesn't have the concept of a baud rate, and so no begin(baud) function.

This is what I mean:

class Esp8266 {

public:
    Esp8266();
    void begin(Stream &wifiCom, Stream &debugCom);
private:

    Stream *_wifiCom;
    Stream *_debugCom;

};

Esp8266::Esp8266() {
}

void Esp8266::begin(Stream &wifiCom, Stream &debugCom) {
    _wifiCom = &wifiCom;
    _debugCom = &debugCom;

    while (!_debugCom) {
        ;
    }
}

Esp8266 esp;

void setup() {
    Serial.begin(115200);
    Serial1.begin(115200);
    esp.begin(Serial, Serial1);
}  // end of setup

void loop() {
}  // end of

Note, as well, my use of pass-by-reference (Stream &whatever) so you don't have to pass a pointer in your begin function.  Also notice the use of unique variable names in the class (I always prefix my member variables with _) so you don't have to keep putting this-> in everywhere.

To be able to move the .begin() function inside your class you will have to use both HardwareSerial and Serial_ object types within your class.  There's two ways this may be done.

First is dynamic casting:

void Esp8266::begin(Stream &wifiCom, Stream *debugCom) {
    _wifiCom = &wifiCom;
    _debugCom = &debugCom;

    HardwareSerial *hard;
    Serial_ *cdc;

    if (hard = dynamic_cast<HardwareSerial*>(_wifiCom)) {
        hard->begin(115200);
    } else if (cdc = dynamic_cast<Serial_*>(_wifiCom)) {
        cdc->begin(115200);
    }

    if (hard = dynamic_cast<HardwareSerial*>(_debugCom)) {
        hard->begin(115200);
    } else if (cdc = dynamic_cast<Serial_*>(_debugCom)) {
        cdc->begin(115200);
    }

}

I haven't tested this, and I don't know if the Arduino's cut-down C++ library is even capable of it, but it's worth a try.

The other method is to overload the .begin() function of your class with multiple versions that take different parameters:

void Esp8266::begin(Serial_ &wifiCom, HardwareSerial *debugCom) {
    _wifiCom = &wifiCom;
    _debugCom = &debugCom;
    wifiCom.begin(115200);
    debugCom.begin(115200);
}

void Esp8266::begin(HardwareSerial &wifiCom, HardwareSerial *debugCom) {
    _wifiCom = &wifiCom;
    _debugCom = &debugCom;
    wifiCom.begin(115200);
    debugCom.begin(115200);
}

void Esp8266::begin(HardwareSerial &wifiCom, Serial_ *debugCom) {
    _wifiCom = &wifiCom;
    _debugCom = &debugCom;
    wifiCom.begin(115200);
    debugCom.begin(115200);
}

You're still storing them internally as Stream objects in all cases, but within the begin() function itself you also have them available as their child classes.  It does mean you have duplicate code copied between the different versions of begin().  You could modularize it a little more though by moving the duplicated code into functions which would only need to be duplicated twice, not three times - one to act on a single Serial_ object and one to act on a single HardwareSerial object:

void Esp8266::initSerial(Serial_ *ser) {
    ser->begin(115200);
}

void Esp8266::initSerial(HardwareSerial *ser) {
    ser->begin(115200);
}

void Esp8266::begin(Serial_ &wifiCom, HardwareSerial *debugCom) {
    _wifiCom = &wifiCom;
    _debugCom = &debugCom;
    initSerial(&wifiCom);
    initSerial(&debugCom);
}
... etc x3 ...


Problem with sending IR with at ATMega328P-PU

NOTE: The following comment was left on this answer (below) and indicates the principal problem the original poster was having above and beyond not having a resistor, etc.

SOLVED - my breadboard was broken on that rail. :/

Current limiting
What you have pictured looks alright for the most part with the exception of there appearing to be no current limiting resistor for the IRED.  It is possible that you've damaged the IRED by setting the pin HIGH for an extended period of time.  It is also technically possible to have damaged the AVR (or just the one pin) by doing that, though this wouldn't be my first guess.
Typical forward voltages for an IRED around around a volt.  An AVR pin's maximum rating current is 40mA.  To get proper logical levels out of it, it should be less than 20mA.  You could perhaps operate near 30mA, since you're not doing much else with the AVR's ports and you're not trying to get logic level voltages out of the pin.  For that you'd need a resistor in series with the IRED that is something like  (5V - 1V) / 0.030A, approximately 133 ohms.

Transistors
When people use IRED to make remotes, it is normal to use a transistor to offload the current requirement from the MCU.  And also to operate the IRED above its continuous operation current, closer to it's rated peak/pulse current.  Operating in the low tens of mA often only gets you a meter or so.
That arrangement might look something like the following for higher current pulses around 80mA:

Asides

I'm not able to read your reset resistor well.  If you're not, do measure it to make sure it's 10K.  If in doubt, remove it.  There is a weaker internal pullup on the AVR reset and it's usually enough.  If you wanted you could wire the reset signal over to the UNO reset pin to take advantage of the external pullup, reset switch, and DTR reset mechanism of the UNO itself.

You may want to add .1uF capacitors from your VCC and AVCC pins to ground.  You can often go without while experimenting, but when you're switching higher currents they'll become more important.

I have a bunch of those jumpers with the rounded (cylindrical) ends.  They often don't make good connections on breadboard.  You can save some trouble sometimes with "Dupont" type jumpers or just making your own out of solid 22awg hookup wire.


The bytes are received to rx buffer with interrupt in the core. The find() function finds them there after the 500 millis delay. Timeout is to wait for the next byte if the rx buffer is empty.

The timeout is good if you know that the other side sends a collection of characters or bytes. Like for example a line sent from Serial Monitor or a Http request on networking client. The transmition has small gaps between bytes, but you want to receive it at once. So a function waiting a little for the next byte is useful.

Serial, networking Client classes and other Arduino stream classes inherit reading functions from the Stream class. This class has all the read and parse functions. There are 3 non blocking functions available, read and peek. All other read and parse functions use the timeout and wait for the next byte if the rx buffer is empty.

try this sketch with Serial Monitor

void setup() {
  Serial.begin(115200);
  Serial.setTimeout(10000);
}

void loop() {
  if (Serial.available()) {
    String s = Serial.readString();
    s.trim();
    Serial.println(s);
  }
}

send a line from Serial Monitor. a couple of characters. then send fast another line and then wait longer then 10 secs and send one more.


If you are using an LED to indicate that your sketch is running, then that may be the problem.

For example, if you have a fairly average red LED, it might have a forward voltage of 2.0v @ 20ma (refer to your spec sheet for your particular LED). Putting these values into the LED calculator, it would tell you that you need a 150 ohm resistor. You might have tested this, and seen the LED light up.

Then, if you drop the voltage to 3.3v, your LED might be either very dim, or (more likely!) not light up at all. Putting 3.3v into the same web page, it shows you need a smaller resistor, 68 ohm, for the same LED.

P.S. - I just noticed your paragraph about the green LED - a "true green" LED might have a voltage drop of 3.3v, which means for 5v you would need a 100 ohm resistor (as described in your paragraph); for a 3.3v supply you would need a 1 ohm resistor instead. This is pretty certainly your problem


Help Troubleshooting L298n connected to dc motor

I realized that I had the jumper disconnected from the ENB pins, which immediately solved the problem when I reconnected it, so it is now fixed!


How to fix baud rate when hardware capacity has a low limit?

The transmitter you're using is very basic, and only transmits "on" and "off". As such it is protocol-agnostic. In order to use it effectively we use it with a protocol that uses "on" and "off" as its signalling, but also includes framing information so that we can know when the data flow starts and stops.

One such protocol is the UART protocol consisting of 1 start bit, 5 to 9 data bits, an even, odd, or no parity bit, and 1, 1.5, or 2 stop bits, all being generated at a specific rate. This rate is the "baud rate", and must match in both the sending device's and the receiving device's UART in order for them to communicate. This is true whether the devices are connected by a wire, an optical link, or a radio link.

The TX and RX pins on an Arduino are connected to a hardware UART which will handle the framing and signal generation for you. The hardware UART(s) can be accessed via Serial on non-USB-native Arduinos as well as Serial1, Serial2, and Serial3 on Arduinos where they are present.

Additionally, SoftwareSerial can be used to generate a UART signal on arbitrary pins in software, but you're almost always better off using a hardware UART when possible.


As to why this happens: connecting to the Arduino with the built in USB port would wipe the display because the Arduino would reset and re-initiate the display initialization routine. The spike in current was actually the initialization signal. In the bare minimum sketch the signal going high, low, then back high was again due to the Arduino resetting.
The solution I'm going with is just changing how I connect to my Arduino with python by adding dsrdtr = 1 to my serial declaration. I tested this and my Arduino no longer resets, and uploading sketches is not impacted.
# Python 3.7.5
import serial
ser = serial.Serial('COM4', 115200, timeout=0, parity=serial.PARITY_NONE,
                   rtscts=1, dsrdtr = 1)


It will wrap around though 0.

0xFFFFFFFF + 1 = 0

You can add a higher order word to track more data:

if (byteWritten > 0) {
    uint32_t newUsed = usedBytes + byteWritten;
    if (newUsed < usedBytes) {
        fourGigsUsed ++;
    }
    usedBytes = newUsed;
}

Or you could use uint64_t to automate it - however none of the Arduino print routines cope with the uint64_t variable type.


Reading an MCP23S17 I/O expander port with the Arduino SPI library

It's working now.  Here is what was missing:
A yellow jumper from the micro-controller MOSI pin to the MCP23S17 SO pin.
So the read command can travel from micro-controller to MCP23S17.


How to digital read and send the data through serial to PC with speed around 2 MHz?

In short? You can't.

To have a 2MHz transmission you need 2*Nbit MHz of serial clock to send it to the PC, where Nbit is the number of bits per sample. Since the minimum is 8, englecting the synchronization or additional bits the serial clock has to be at least 16MHz. Which is the system clock of the nano. So no way.

Now, with the alternatives. First question: what is your ADC's interface? I found the LTC2204. It is a parallel ADC, so you need something to convert it to anything readable by the PC.

I'm not sure about the feasibility of this, but a nano is not enough. I'd use an STM32 (because I have their Nucleo boards, but you can search for other 32-bit boards) and a high speed serial interface. Since even SPI can be slow, maybe ethernet needs to be used. I was not able to search for boards with native ethernet interface; anyway the STM32F4 microcontrollers should (see this article) have an ethernet interface and you will "only" need the PHY. I think that this is the only applicable way to follow..


Most likely, the Serial3 buffer is being overrun because you are not reading fast enough. That is why when you use a simple loop, everything works and you get the whole message; very little time passes between reads. The simplest solution to this is to increase the size of the Serial buffer to, maybe, 256 bytes. Search for HardwareSerial.h in your Arduino installation and look for the #defined variable SERIAL_RX_BUFFER_SIZE in the file near the top. Change its value to 256 and save. This should provide enough buffer space to store the entire SMS until you read it.
Alternatively you could change your CNMI settings to push only SMS notifications, which are a lot smaller in size, to the Arduino. Then you can parse the notifications, extract the SMS index and then request the SMS from the SIM800 using the index whenever you wish, making sure to read quickly (you will need to craft a while loop to do this efficiently, with timeouts and all).


The flash memory is connected to io 6 to io 11 if it is connected in QIO mode. DIO mode lets two of the pins free. According to Arduino core reference the two pins are 9 and 11. The flash pins are labeled SD and most of them are the first SPI interface of the esp8266. You can't use this SPI pins as digital pins, but supposedly you can connect another SPI device.

Some of the esp8266 'free' pins have some restrictions. Boot configuration pins io 0, io 2 and io 15 need to have some state at boot. io2 not LOW, io 15 LOW and with io 0 flashing mode is activated. The A0 is ADC only pin. And you can't count power, EN, Reset and ground as 'pins'.

You can use a multiplexer or an I2C expansion board to get more pins.


You omitted the protocol part of the url. The HttpClient implementation requires it.

Use http.begin("http://www.francescosoave.com/blind/getTime.php");

Do not use Content-type header. You do not send any content.

Turn-on debug in Tools menu. Set Debug Port to Serial and Debug Level to HTTP_CLIENT to see the error messages.


sprintf() to assemble String and float pieces locks up

This variable:

String utcDateString = "";

Is a C++ String, not a character array like sprintf() is expecting.  To convert this string to a character array such that sprintf is expecting, you must use .c_str() in your sprintf, i.e.:

sprintf(foo,"This is a format for %s", utcDateString.c_str());

Doing this should prevent the sprintf line from causing a memory fault.