text:
Why is Arduino resetting while driving motors?
I am driving motors for my line-follower project . The circuit schematic is given below
The power source is a 11.1V 2200mAh 25C Lipo . Practically the cells give 11.5-12V. I used a switching buck regulator to step down the voltage. However , when i run my robot on track after few seconds,the arduino tends to reset and run again. This problem typically arises when i drive the motors at higher PWM(above 180 on analogWrite function). Since i use PID, limiting the PWM means i have to drive at lower speeds which i do not want.
I am providing links for the items i used for my circuit:

buck converter;
motor driver;
IR sensor module;
DC motors.

The sensor array draws 150mA at peak. Any suggestions as to where the problem might lie would be of great help. Thank you .
EDIT 1: Changed the input voltage Vin to 7.9V through the buck converter .
        The problem still persists .

The buck converter is producing 5.5 V?  That may be too low for the VIN input on Arduino, where the voltage regulator needs at least 7 V and is therefore causing brown-out.

The VIN pin goes to a 5V voltage regulator on the Arduino and needs at least about 7V minimum to work properly.  If you want to supply 5V to an Arduino do it either on the 5V pin or via the USB connector.  The VIN pin should receive 7V to 12V.

This is the correct answer. VIN a high enough voltage to be regulated down to 5V. I suggest feeding 5V into your USB connector. That way you don't bypass the source switching and protection circuitry on the Arduino.

@DuncanC Doesn't the USB connector also have a regulator, or does it expect that the USB can consistently provide 5V?

@MindS1, read https://store.arduino.cc/mega-2560-r3

No, USB provides regulated 5V, and is fed through some logic and current limiting circuits to the +5V rail. The Arduino uses a linear regulator, which needs a couple of volts more than it's target voltage. (IT works by applying a variable resistance to the input, converting the excess voltage to heat. )

You might get away with feeding 5V into the VIN if you draw VERY low current from it, and if there is no voltage sag, but it's not recommended.

I changed the Vin to near 7V , but the resetting problem still persists . Yes , now it happens less frequently , but when the motor starts moving at full/high speed(PWM>210) after breaking , the mega resets .

It is likely your motors are drawing too much current from the battery when running at high speed.  What is the max continuous current rating for the battery?  How much current are the motors using at high speed?

@JeffWahaus , my motors draw 2-2.5A each when stalled running at full speed. Power source is 11.1V 2200mAh 25C 3cell Lipo battery.

Resetting is due either to a software bug or voltage sag, and since it correlates with driving the motors harder, it's almost certainly the latter. You probably suspected as much since you mentioned the current draw of the sensor array. A quick experiment - disconnecting the sensors (and possibly a software patch to keep the robot running straight, without them) might help you discover the reason.
Each chip and each of its pin drivers has a current budget. It would be a good idea to look at the max current spec of the Atmega2560 and its pin drivers, and any other current specs mentioned in the datasheet, and make sure you're not trying to run it out of spec. The buck converter will have a limit, too, so make sure you're within its spec. If the output regulation of the buck converter is good enough, you can regulate it to 5v and bypass the Mega's on board regulator, for another saving.

One major drawback to working with motors is the large amounts of electrical noise they produce. This noise can interfere with your sensors and can even impair your microcontroller by causing voltage dips on your regulated power line. Large enough voltage dips can corrupt the data in microcontroller registers or cause the microcontroller to reset. You can avoid this problem by soldering capacitors along your motor terminals. Use 1µF ceramic capacitors for example

Why the down-vote? Everything in this answer is good advice. Motors introduce a lot of noise on the power input. Adding filter capacitors is a very good idea. (That said, the biggest problem is likely too low an input voltage to VIN)

I've experienced this myself too.  Also vibration causing wires to become loose.

This might be a good idea . I noticed the voltage up/down surge problems on start-up initially or after breaking . On which type of motors do you use these capacitors ? Do they affect the motor performance ?

@user9999114 On brush motors mostly. They don't have an affect (that I one could notice) on the motor perfomance

This is the common issue when trying to connect power and digital circuits together. Probably, when motor starts, there is a short-time voltage drop in Vin due to high motor start current. Consider to use Schottky diode and capacitor to protect digital power circuit from transitional currents.

You should either feed the 5.5v from the buck converter to the 5v pin of the arduino, or the 11.5v to the Vin.
The arduino board contains its own 5v converter (and a 3.3v but that's not in question here). That takes the voltage of the Vin pin and converts it to 5v for the board to use. This regulated 5 v is available on the 5v pin for your sensors for example.
You can also power it directly on the 5v pin, but that requires regulated 5v. This is also how it is powered through USB which supplied regulated 5 v.
The 5.5 v from your buck should be fine for this, by you don't need it. Put the "raw" 11.5 to the Vin pin.


text:
WindowsError(31, 'A device attached to the system is not functioning.') in arduino
Having board esp32 devkit v1, to get started with arduino ide (installed recommended boards for esp32) I marked board asDOIT ESP32 DEVKIT V1 (as no other options as like ESP32 DEVKIT V1 ) so upload gets this error
    esptool.py v2.6
Serial port COM3
Traceback (most recent call last):
File "esptool.py", line 2959, in <module>
File "esptool.py", line 2952, in _main
File "esptool.py", line 2652, in main
File "esptool.py", line 222, in __init__
File "site-packages\serial\__init__.py", line 88, in serial_for_url
File "site-packages\serial\serialwin32.py", line 62, in open
serial.serialutil.SerialException: could not open port 'COM3': WindowsError(31, 'A device attached to the system is not functioning.')
Failed to execute script esptool
the selected serial port Failed to execute script esptool
 does not exist or your board is not connected

so how do I upload my programs?
I would be highly obliged if you could please help me solve this problem.
Thank you.

are you sure COM3 is the correct port?

It's only available

is that trying to say that COM3 is the only one available? if you disconnect the ESP, does COM3 also disappear?

Have you installed the CP2102 drivers?

Yupp if I disconnect esp com3 disappeared

No I haven't install that drivers

I am facing trouble with the same error. Did it get solved? I tried with both the DM board and AI thinker, but this error doesn't seem to get removed at all

I got this error.  Then switching USB ports fixed the problem.  Showed up on COM3 in either place. I just switched from a built-in USB port to on off a hub, and it started working.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Arduino Uno with 6x 5V solenoids + 9V battery - Not enough power?
I have 6 5V solenoids connected to an Arduino Uno, each of them with a TIP120 transistor, diode and resistor. Exactly like https://core-electronics.com.au/tutorials/solenoid-control-with-arduino.html but 6 times. I'm using a 9V battery connected to the DC input, as well as USB input to my PC.
Now the problem is that if I activate 5 or 6 solenoids at once, the Arduino seems to get interrupted / lose all power for a second (disconnect sound from the PC and no activity). I've tested them one by one and everything works, but I can activate at most 4 solenoids at once.
What am I missing? Do I need more power?

I'm using a 9V battery connected to the DC input

Well, there's your problem. Those 9V PP3 batteries are barely enough to power the Arduino by itself. Add anything like motors and solenoids and you're going to have problems. Big problems.
Ditch the PP3 battery. It's only suitable for very low current devices, like smoke alarms. For anything more you need at least multiple series AA batteries.
Also the solenoids must be powered direct from your power source (or through their own regulator if needed), since the Arduino's on-board regulator will go into thermal shutdown quite quickly with 9V in and a large current draw.

I should've mentioned I've also tried a 6x AA battery pack on DC, it gave the same results. And I'm not sure how I can connect them directly to my power source?

@SJ19 Take the wire out of the 5V pin on the Arduino and connect it to your battery + (assuming the battery isn't too high a voltage for your solenoid).

Thank you! Guess I should be looking for a battery connector with wires then. Excuse my ignorance but do you reckon a 9V battery will be too much for the 5V solenoids?

@SJ19 If they are actually 5V solenoids, then yes probably. You will want a 5V regulator. Get a UBEC from an RC model seller - they're the simplest option.

Another possibility is to use latching solenoids controlled by an H-bridge so that they only need power to turn on or turn off. However, I don't know if they are available for your application. When I looked into latching irrigation valves they were much more expensive than simple solenoid valves.

You're experiencing a lack of available current. When the solenoids are operating, the system is trying to draw more current than the battery can provide, so what happens instead is the voltage starts to drop. (I can't remember exactly why this happens right now). When this happens the arduinos power supply detects an under-voltage condition and shuts down, but as soon as it shuts down the current draw tanks and the voltage rises again causing the system to restart. Essentially, the answer to this is to provide your system with a larger current source and the problem should go away.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Arduino delay inside of an Interrupt
Using the delay function inside of an ISR is frowned upon when programming in an Arduino. The general response to solve this desire is to design the program to delay in a more cleanly way outside of the interrupt.
My question is simply why. Why does putting a delay() inside of an ISR cause wonky behavior with the Arduino. Whats going on under the hood?

Why is putting a delay() inside of an ISR cause wonky behavior with the Arduino. Whats going on under the hood?

The first problem is that delay() is a busy loop monitoring millis(). The value that millis() returns will not change inside an ISR as interrupts are turned off inside an ISR; this is why ISRs must be as short and fast as possible, or they will interfere with other interupts
So if you call delay() within an ISR your poor AVR is now deadlocked! It is waiting for something to happen that can now never happen.
A second problem is that if your ISR takes too long, you can miss other interrupts; millis() and micros() can miss ticks and become inaccurate!

Because a delay inside an interrupt causes that interrupt and other (lower priority) interrupts not to execute anymore until the delay is over.
Assume in an ISR you handle the incoming bytes from a UART. If you add a delay in the ISR, and the buffer of the UART gets full, it will overflow and you miss bytes.

This is an addition to esoterik's answer.
Most of the times, that people try to use delay() inside an ISR it is a poor design choice to even use it in a general way, that will lead to the described problems (waiting forever or missing other interrupts). delay() is a simple function mainly for beginners with very simple programs. It is a simple starting point. Mostly the use of it in any program is not a good choice, since you are busy waiting without being able to do something else (like responding to user input). There are better ways, involving millis() itself, that keep your program extendable (so that, if you want to add a functionality, this will not be blocked by the first part of the code). And when your program reaches the complexity of using own ISRs, you should avoid delay(), unless you really know, what you are doing.
IMO at some (rather early) point, every Arduino programmer has to learn how to use millis() to do timed code execution. You can look at the BlinkWithoutDelay example, that comes with the Arduino IDE.


text:
How to safely remove arduino nano from breadboard?
I did some prototyping with arduino nano in breadboard. And then after i done with the design, I was gonna implement it in a printed pcb so i need to remove the nano from breadboard. And this is when the disaster happened.
The board is kinda hard to pull by hand, so i use a long-thin screwdriver in the gutter to pull the nano up (just like i did many times to dip ICs with no problem). And successfully detached the nano from breadboard and also broke the tantalum under the nano in the process. So the question is:

How do you usually remove the nano board from breadboard safely? And
The tantalum i broke is 4.7uF smd. I can't find any 4.7uF tantalum in nearby shops, but i have electrolyte caps rated 4.7uF 16v. Can i use it for replacement?

Use long and wide screwdriver. put the tip under the board. Do not pull! Gently twist the screwdriver. After few millimeters do the same from the other side. After several such operations nano will be free with no pins bent, and no hardware damaged. For additional safety substitute screwdriver with something plastic.

What you really want is one of the long black plastic spudgers. Metal screwdrivers are asking for trouble. Plastic will flex more than the components.

How do you usually remove the nano board from breadboard safely? And

If you can't remove it by hand (grip it lengthwise and ease up each end with your finger / thumb levering against the breadboard) then you need a lever. The best is a plastic spudger, such as this:

The plastic will flex rather than damage the Arduino. Using a screwdriver can, as you have noticed, damage the Arduino.

The tantalum i broke is 4.7uF smd. I can't find any 4.7uF tantalum in nearby shops, but i have electrolyte caps rated 4.7uF 16v. Can i use it for replacement?

Sure. All that is, is a reservoir capacitor on the USB input. The value isn't super-critical, as long as the voltage is above 5V. It's not, strictly speaking, even needed. You can just remove it completely and clean up the pads to ensure there's no shorts. The board should still work fine.

I also had the same problem but what I had done was, I pressed the breadboard with my leg and used my all fingers to grip the nano and pulled it with my full force and then it is done. And no parts were damaged and id you lost any part you can search on https://octopart.com/ .

And if you just broken the whole you need to buy a new one. Or if not follow my answer.


text:
Adafruit RGB LCD w/ Shield kit connection to arduino uno?
I have a adafruit rbg 16x2 lcd with shield kit and am trying to connect it to an arduino uno. The only thing is the assembly instructions have the lcd basically using every pin on the arduino, even tho it says its not for connections. Since we are using many of the pins already on the board, can I wire it to the board without soldering it to every pin, essentially only wiring to the few necessary pins?
Sorry, I am very new at this. Thank you for the help.
EDIT: Was essentially looking for the follwing diagram. Thanks to all!

Every pin, that is not electrically used by the shield can be used for other purposes. It is not clear, what is preventing you from doing so? Is it just, that the shield blocks all the other pins (without using them)?

The idea of shields is that they (in theory) can be stackable.
(In practice they are usually not)
This means that technically you can do this:

That's why by design every shield connects to every Arduino pin but uses only some of them. That way shield is mechanically well attached to the Arduino, and can pass "unused" pins to the shield above it.
Your shield is designed to be always "on top" so I think it only connects to some pins just for mechanical support. Technically the LDC screen needs only 6 pins and 1 pin per button.
EDIT:
I read now that the shield you got uses only 2 pins and communicates using I2C bus (which is perfect) so I'm 100% sure that it's designed to be on top of the stack and work together with other shields and uses extra pins for mechanical support.


text:
Replicate output of pwm pin on another output pin?
Ardiuno Mega 2560
I have a legacy PCB that connects PORTA, pins = {22, 23, 24, 25, 26, 27, 28, 29} to the PWM input of a set of actuators. The accompanying code made use of an interupt service routine to generate PWM signals. This in turn caused all sorts of other problems for the system.
So, I would like to leverage the Mega's internal counters & use the PWM available on pins = {2, 3, 4, 5, 6, 7, 8, 9} & use the analogWrite() function. At present there is nothing else connected to these pins but access is limited.
Before I go down the route of redesigning the PCB I was wondering if it was possible to replicate the outputs of pins {2, 3, 4, 5, 6, 7, 8, 9} to pins {22, 23, 24, 25, 26, 27, 28, 29}?

It is not clear, what you are trying to achieve. What I understood is: You want do measure the value of the PWM signal on the pins {22, 23, 24, 25, 26, 27, 28, 29} and then outputting a new PWM signal with the same value on the pins {2, 3, 4, 5, 6, 7, 8, 9}. Is that correct?

I want to generate the PWM on pins {2, 3, 4, 5, 6, 7, 8, 9} using analogWrite() but replicate that output on pins {22, 23, 24, 25, 26, 27, 28, 29}

It is not possible to route pins to other pins, the functionality of a pin is fixed to that pin. You could try a software pwm library.

Is there a reason, why you want the same PWM signal on more than 1 pin? Why don't you just connect the one pin to both targets?

as mentioned in the orginal post the issue is to do with a legacy PCB. I'm just soundng out options before I have to redesign anything

Internally, it's not possible. If pins 22 through 29 are not used for anything else, soldering jumper wires onto a spacer or directly onto the PCB might be an option.
Otherwise, as @Jot suggested, software PWM is always an option, but they achievable frequency would be limited.

As Jot wrote, you cannot simply route a signal from pin to pin inside the chip/Arduino. So - unless you redesign the PCP, which would be the cleanest way, or use jumper wires, which is not so clean - you are down to using software PWM. There are also libraries for this, if you don't want to write this yourself, for example the SoftPWM library. These libraries have their own limits, especially in frequency. Be sure to check, if they fit your needs.

will check out the linked library tomorrow thanks. Is there any reason you can think of why I couldnt hard wire the pins together?

You can. This is only about how clean the solution would be. Of course it is best to have a PCB thats designed for it. Connecting the pins with jumper wires is a bit less clean, but will work well (as long, as you don't need these pins for other purposes)


text:
Cant get rid of Soft WDT reset using ESP8266
Im using ESP12E DevKit v2 (esp8266 wifi module) board for controlling relays and displaying DHT22 temp,humidity on web server. It runs smoothly but after while i always get a watchdog timer reset. (If i have serial monitor opened up it happens quicker)
I tried adding more delays, yield function, removing serial prints that i use for debugging but nothing helps.
I think it can be caused because my website is being refreshed every 1sec, because i want to display current time and most recent temp,humidity and this was the easiest way to do it. But this WDT reset problem appeared just recently after i added more code and functionality to my site.
Could anyone have a look at my code and give me some advice on what could help or cause the problem?
Arduino code:

// Including the needed libraries
#include <ESP8266WiFi.h>
#include <DHT.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#define DHTTYPE DHT22 // Defining DHT sensor type

// Network details
const char* ssid = "Connection1";
const char* password = "pass";

// Define NTP Client to get time
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP);

// Set web server port number to 80
WiFiServer server(80);

// Variable to store the HTTP request
String header;

// Decode HTTP GET value
String valueString = "0";
int pos1 = 0;
int pos2 = 0;

// Variables to store the current output state
String relay0State = "on";
String relay1State = "off";
String relay2State = "off";
String brightness = "0";

// Variables to save date and time
String formattedDate;
String dayStamp;
String timeStamp;

// Variables assigned to pins
const int relay0 = 16;
const int relay1 = 5;
const int relay2 = 4;
const int DHT1Pin = 0;
const int DHT2Pin = 2;

// Initialize DHT sensors
DHT dht1(DHT1Pin, DHTTYPE);
DHT dht2(DHT2Pin, DHTTYPE);

void setup() {
  Serial.begin(115200);
  // Initialize the output variables as outputs
  pinMode(relay0, OUTPUT);
  pinMode(relay1, OUTPUT);
  pinMode(relay2, OUTPUT);
  // Set outputs to LOW
  digitalWrite(relay0, LOW);
  digitalWrite(relay1, LOW);
  digitalWrite(relay2, LOW);

  dht1.begin();
  dht2.begin();

  // Connect to Wi-Fi network with SSID and password
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);
  delay(3000);
  while (WiFi.status() != WL_CONNECTED) {
    delay(300);
    Serial.print(".");
  }

  // Print local IP address and start web server
  Serial.println("");
  Serial.println("WiFi CONNECTED with IP: ");
  Serial.println(WiFi.localIP());
  server.begin();

  // Initialize a NTPClient to get time
  timeClient.begin();
  // Setting offset time in seconds to adjust for current timezone -> GMT +1 = 3600
  timeClient.setTimeOffset(3600);
}
void loop(){
  WiFiClient client = server.available();   // Listen for incoming clients

   while(!timeClient.update()) {
    timeClient.forceUpdate();
  }
  // The formattedDate comes with the following format 2018-05-28T16:00:13Z
  formattedDate = timeClient.getFormattedDate();
  // Extract date
  int splitT = formattedDate.indexOf("T");
  dayStamp = formattedDate.substring(0, splitT);
  // Extract time
  timeStamp = formattedDate.substring(splitT+1, formattedDate.length()-1);

  if (client) {
    Serial.println("NEW CLIENT");          // Printing a message out in the serial port, if a new client connects
    String currentLine = "";                // String to hold incoming data from the client
    while (client.connected()) {            // loop while the client's connected
      if (client.available()) {             // if there's bytes to read from the client,
        char c = client.read();             // read a byte, then
        //Serial.write(c);                    // print it out the serial monitor
        header += c;
        if (c == '\n') {                    // if the byte is a newline character
          // if the current line is blank, you got two newline characters in a row.
          // that's the end of the client HTTP request, so send a response:
          if (currentLine.length() == 0) {
            // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
            // and a content-type so the client knows what's coming, then a blank line:
            client.println("HTTP/1.1 200 OK");
            client.println("Content-type:text/html");
            client.println("Connection: close");
            client.println();

            // Turns the PINs on and off
          if (header.indexOf("GET /0/on") >= 0) {
              relay0State = "on";
              digitalWrite(relay0, HIGH);
            } else if (header.indexOf("GET /0/off") >= 0) {
              relay0State = "off";
              digitalWrite(relay0, LOW);
            } else if (header.indexOf("GET /1/on") >= 0) {
              relay1State = "on";
              digitalWrite(relay1, HIGH);
            } else if (header.indexOf("GET /1/off") >= 0) {
              relay1State = "off";
              digitalWrite(relay1, LOW);
            } else if (header.indexOf("GET /2/on") >= 0) {
              relay2State = "on";
              brightness = "75";
              digitalWrite(relay2, 191);
            } else if (header.indexOf("GET /2/off") >= 0) {
              relay2State = "off";
              brightness = "0";
              digitalWrite(relay2, 0);
            }

            // Read humidity
            float h1 = dht1.readHumidity();
            float h2 = dht2.readHumidity();
            // Read temperature as Celsius (the default)
            float t1 = dht1.readTemperature();
            float t2 = dht2.readTemperature();
            // Read temperature as Fahrenheit (isFahrenheit = true)
            float f1 = dht1.readTemperature(true);
            float f2 = dht2.readTemperature(true);

            // Calculating average temp and humidity from DHT22 sensors
            float temperature = (t1 + t2)/2;
            float temperaturef = (f1 + f2)/2;
            float humidity = (h1 + h2)/2;

            // Display the HTML web page
            client.println("<!DOCTYPE html>");
            client.println("<meta http-equiv=\"refresh\" content=\"1\" name=\"viewport\" content=\"width=device-width, initial-scale=1\">");
            client.println("");
            client.println("<title>Smart TERA</title>  ");
            client.println("

Smart TERA

");
            client.println(timeStamp);
            client.println(" / " + dayStamp);
            client.println("

Temperature: ");
            client.println(temperature);
            client.println("℃ /  ");
            client.println(temperaturef);
            client.println("℉

Humidity: ");
            client.println(humidity);
            client.println("%

Light Brightness:  %
 <input class=\"slider\" type=\"range\" min=\"0\" max=\"100\" step=\"25\" value="+brightness+" id=\"myRange\">");
            client.println("
");

            if(header.indexOf("GET /?value=")>=0) {
                pos1 = header.indexOf('=');
                pos2 = header.indexOf('&');
                valueString = header.substring(pos1+1, pos2);
                if(valueString == "0" ){
                  relay2State = "off";
                  brightness = "0";
                  digitalWrite(relay2, 0);
                } else if (valueString == "25"){
                  relay2State = "on";
                  brightness = "25";
                  digitalWrite(relay2, 64);
                } else if (valueString == "50"){
                  relay2State = "on";
                  brightness = "50";
                  digitalWrite(relay2, 128);
                } else if (valueString == "75"){
                  relay2State = "on";
                  brightness = "75";
                  digitalWrite(relay2, 192);
                } else if (valueString == "100"){
                  relay2State = "on";
                  brightness = "100";
                 digitalWrite(relay2, 255);
                }
           }
            // Display current state, and ON/OFF buttons for controlling relays
            client.println("
Rock Heater - State " + relay0State + "
");
            // If the relay0State is off, it displays the ON button
            if (relay0State=="off") {
              client.println("
<button class=\"button\">ON</button>
");
            } else {
              client.println("
<button class=\"button button2\">OFF</button>
");
            }

            client.println("
Humidifier - State " + relay1State + "
");
            if (relay1State=="off") {
              client.println("
<button class=\"button\">ON</button>
");
            } else {
              client.println("
<button class=\"button button2\">OFF</button>
");
            }

            client.println("
Light - State " + relay2State + "
");
            if (relay2State=="off") {
              client.println("
<button class=\"button\">ON</button>
");
            } else {
              client.println("
<button class=\"button button2\">OFF</button>
");
            }
            client.println("
 ");

            // The HTTP response ends with another blank line
            client.println();
            yield();
            // Break out of the while loop
            break;
          } else { // if you got a newline, then clear currentLine
            currentLine = "";
          }
        } else if (c != '\r') {  // if you got anything else but a carriage return character,
          currentLine += c;      // add it to the end of the currentLine
        }
      } yield();
    }
    // Clear the header variable and close the connection
    header = "";
    client.stop();
    Serial.println("CLIENT DISCONNECTED");
   }
}

Error message:
Soft WDT reset

>>>stack>>>

ctx: sys
sp: 3fffed40 end: 3fffffb0 offset: 01b0
3fffeef0:  3ffee990 0abd1a53 60000600 00000001
3fffef00:  00000000 3ffed9d8 00000000 00000000
3fffef10:  4022cf78 3ffed9d8 3ffee990 60000600
3fffef20:  4022f8c1 3ffed9d8 3ffee990 0abd1a53
3fffef30:  4022f906 3fffdab0 00000000 3fffdcb0
3fffef40:  3ffee9b8 3fffdab0 00000000 40205d0f
3fffef50:  40000f49 40000f49 3fffdab0 40000f49
3fffef60:  40000e19 40001878 00000002 00000000
3fffef70:  3fffff10 aa55aa55 000000b4 401048e4
3fffef80:  401048ea 00000002 00000000 3315d4f6
3fffef90:  4010000d 0c060f10 1427fd57 49e0d507
3fffefa0:  40100a84 3fffef3c 40100a31 3ffffe88
3fffefb0:  3fffffc0 00000000 00000000 feefeffe
3fffefc0:  feefeffe feefeffe feefeffe feefeffe
3fffefd0:  feefeffe feefeffe feefeffe feefeffe
3fffefe0:  feefeffe feefeffe feefeffe feefeffe
3fffeff0:  feefeffe feefeffe feefeffe feefeffe
3ffff000:  feefeffe feefeffe feefeffe feefeffe
3ffff010:  feefeffe feefeffe feefeffe feefeffe
3ffff020:  feefeffe feefeffe feefeffe feefeffe
3ffff030:  feefeffe feefeffe feefeffe feefeffe
3ffff040:  feefeffe feefeffe feefeffe feefeffe
3ffff050:  feefeffe feefeffe feefeffe feefeffe
3ffff060:  feefeffe feefeffe feefeffe feefeffe
3ffff070:  feefeffe feefeffe feefeffe feefeffe
3ffff080:  feefeffe feefeffe feefeffe feefeffe
3ffff090:  feefeffe feefeffe feefeffe feefeffe
3ffff0a0:  feefeffe feefeffe feefeffe feefeffe
3ffff0b0:  feefeffe feefeffe feefeffe feefeffe
3ffff0c0:  feefeffe feefeffe feefeffe feefeffe
3ffff0d0:  feefeffe feefeffe feefeffe feefeffe
3ffff0e0:  feefeffe feefeffe feefeffe feefeffe
3ffff0f0:  feefeffe feefeffe feefeffe feefeffe
3ffff100:  feefeffe feefeffe feefeffe feefeffe
3ffff110:  feefeffe feefeffe feefeffe feefeffe
3ffff120:  feefeffe feefeffe feefeffe feefeffe
3ffff130:  feefeffe feefeffe feefeffe feefeffe
3ffff140:  feefeffe feefeffe feefeffe feefeffe
3ffff150:  feefeffe feefeffe feefeffe feefeffe
3ffff160:  feefeffe feefeffe feefeffe feefeffe
3ffff170:  feefeffe feefeffe feefeffe feefeffe
3ffff180:  feefeffe feefeffe feefeffe feefeffe
3ffff190:  feefeffe feefeffe feefeffe feefeffe
3ffff1a0:  feefeffe feefeffe feefeffe feefeffe
3ffff1b0:  feefeffe feefeffe feefeffe feefeffe
3ffff1c0:  feefeffe feefeffe feefeffe feefeffe
3ffff1d0:  feefeffe feefeffe feefeffe feefeffe
3ffff1e0:  feefeffe feefeffe feefeffe feefeffe
3ffff1f0:  feefeffe feefeffe feefeffe feefeffe
3ffff200:  feefeffe feefeffe feefeffe feefeffe
3ffff210:  feefeffe feefeffe feefeffe feefeffe
3ffff220:  feefeffe feefeffe feefeffe feefeffe
3ffff230:  feefeffe feefeffe feefeffe feefeffe
3ffff240:  feefeffe feefeffe feefeffe feefeffe
3ffff250:  feefeffe feefeffe feefeffe feefeffe
3ffff260:  feefeffe feefeffe feefeffe feefeffe
3ffff270:  feefeffe feefeffe feefeffe feefeffe
3ffff280:  feefeffe feefeffe feefeffe feefeffe
3ffff290:  feefeffe feefeffe feefeffe feefeffe
3ffff2a0:  feefeffe feefeffe feefeffe feefeffe
3ffff2b0:  feefeffe feefeffe feefeffe feefeffe
3ffff2c0:  feefeffe feefeffe feefeffe feefeffe
3ffff2d0:  feefeffe feefeffe feefeffe feefeffe
3ffff2e0:  feefeffe feefeffe feefeffe feefeffe
3ffff2f0:  feefeffe feefeffe feefeffe feefeffe
3ffff300:  feefeffe feefeffe feefeffe feefeffe
3ffff310:  feefeffe feefeffe feefeffe feefeffe
3ffff320:  feefeffe feefeffe feefeffe feefeffe
3ffff330:  feefeffe feefeffe feefeffe feefeffe
3ffff340:  feefeffe feefeffe feefeffe feefeffe
3ffff350:  feefeffe feefeffe feefeffe feefeffe
3ffff360:  feefeffe feefeffe feefeffe feefeffe
3ffff370:  feefeffe feefeffe feefeffe feefeffe
3ffff380:  feefeffe feefeffe feefeffe feefeffe
3ffff390:  feefeffe feefeffe feefeffe feefeffe
3ffff3a0:  feefeffe feefeffe feefeffe feefeffe
3ffff3b0:  feefeffe feefeffe feefeffe feefeffe
3ffff3c0:  feefeffe feefeffe feefeffe feefeffe
3ffff3d0:  feefeffe feefeffe feefeffe feefeffe
3ffff3e0:  feefeffe feefeffe feefeffe feefeffe
3ffff3f0:  feefeffe feefeffe feefeffe feefeffe
3ffff400:  feefeffe feefeffe feefeffe feefeffe
3ffff410:  feefeffe feefeffe feefeffe feefeffe
3ffff420:  feefeffe feefeffe feefeffe feefeffe
3ffff430:  feefeffe feefeffe feefeffe feefeffe
3ffff440:  feefeffe feefeffe feefeffe feefeffe
3ffff450:  feefeffe feefeffe feefeffe feefeffe
3ffff460:  feefeffe feefeffe feefeffe feefeffe
3ffff470:  feefeffe feefeffe feefeffe feefeffe
3ffff480:  feefeffe feefeffe feefeffe feefeffe
3ffff490:  feefeffe feefeffe feefeffe feefeffe
3ffff4a0:  feefeffe feefeffe feefeffe feefeffe
3ffff4b0:  feefeffe feefeffe feefeffe feefeffe
3ffff4c0:  feefeffe feefeffe feefeffe feefeffe
3ffff4d0:  feefeffe feefeffe feefeffe feefeffe
3ffff4e0:  feefeffe feefeffe feefeffe feefeffe
3ffff4f0:  feefeffe feefeffe feefeffe feefeffe
3ffff500:  feefeffe feefeffe feefeffe feefeffe
3ffff510:  feefeffe feefeffe feefeffe feefeffe
3ffff520:  feefeffe feefeffe feefeffe feefeffe
3ffff530:  feefeffe feefeffe feefeffe feefeffe
3ffff540:  feefeffe feefeffe feefeffe feefeffe
3ffff550:  feefeffe feefeffe feefeffe feefeffe
3ffff560:  feefeffe feefeffe feefeffe feefeffe
3ffff570:  feefeffe feefeffe feefeffe feefeffe
3ffff580:  feefeffe feefeffe feefeffe feefeffe
3ffff590:  feefeffe feefeffe feefeffe feefeffe
3ffff5a0:  feefeffe feefeffe feefeffe feefeffe
3ffff5b0:  feefeffe feefeffe feefeffe feefeffe
3ffff5c0:  feefeffe feefeffe feefeffe feefeffe
3ffff5d0:  feefeffe feefeffe feefeffe feefeffe
3ffff5e0:  feefeffe feefeffe feefeffe feefeffe
3ffff5f0:  feefeffe feefeffe feefeffe feefeffe
3ffff600:  feefeffe feefeffe feefeffe feefeffe
3ffff610:  feefeffe feefeffe feefeffe feefeffe
3ffff620:  feefeffe feefeffe feefeffe feefeffe
3ffff630:  feefeffe feefeffe feefeffe feefeffe
3ffff640:  feefeffe feefeffe feefeffe feefeffe
3ffff650:  feefeffe feefeffe feefeffe feefeffe
3ffff660:  feefeffe feefeffe feefeffe feefeffe
3ffff670:  feefeffe feefeffe feefeffe feefeffe
3ffff680:  feefeffe feefeffe feefeffe feefeffe
3ffff690:  feefeffe feefeffe feefeffe feefeffe
3ffff6a0:  feefeffe feefeffe feefeffe feefeffe
3ffff6b0:  feefeffe feefeffe feefeffe feefeffe
3ffff6c0:  feefeffe feefeffe feefeffe feefeffe
3ffff6d0:  feefeffe feefeffe feefeffe feefeffe
3ffff6e0:  feefeffe feefeffe feefeffe feefeffe
3ffff6f0:  feefeffe feefeffe feefeffe feefeffe
3ffff700:  feefeffe feefeffe feefeffe feefeffe
3ffff710:  feefeffe feefeffe feefeffe feefeffe
3ffff720:  feefeffe feefeffe feefeffe feefeffe
3ffff730:  feefeffe feefeffe feefeffe feefeffe
3ffff740:  feefeffe feefeffe feefeffe feefeffe
3ffff750:  feefeffe feefeffe feefeffe feefeffe
3ffff760:  feefeffe feefeffe feefeffe feefeffe
3ffff770:  feefeffe feefeffe feefeffe feefeffe
3ffff780:  feefeffe feefeffe feefeffe feefeffe
3ffff790:  feefeffe feefeffe feefeffe feefeffe
3ffff7a0:  feefeffe feefeffe feefeffe feefeffe
3ffff7b0:  feefeffe feefeffe feefeffe feefeffe
3ffff7c0:  feefeffe feefeffe feefeffe feefeffe
3ffff7d0:  feefeffe feefeffe feefeffe feefeffe
3ffff7e0:  feefeffe feefeffe feefeffe feefeffe
3ffff7f0:  feefeffe feefeffe feefeffe feefeffe
3ffff800:  feefeffe feefeffe feefeffe feefeffe
3ffff810:  feefeffe feefeffe feefeffe feefeffe
3ffff820:  feefeffe feefeffe feefeffe feefeffe
3ffff830:  feefeffe feefeffe feefeffe feefeffe
3ffff840:  feefeffe feefeffe feefeffe feefeffe
3ffff850:  feefeffe feefeffe feefeffe feefeffe
3ffff860:  feefeffe feefeffe feefeffe feefeffe
3ffff870:  feefeffe feefeffe feefeffe feefeffe
3ffff880:  feefeffe feefeffe feefeffe feefeffe
3ffff890:  feefeffe feefeffe feefeffe feefeffe
3ffff8a0:  feefeffe feefeffe feefeffe feefeffe
3ffff8b0:  feefeffe feefeffe feefeffe feefeffe
3ffff8c0:  feefeffe feefeffe feefeffe feefeffe
3ffff8d0:  feefeffe feefeffe feefeffe feefeffe
3ffff8e0:  feefeffe feefeffe feefeffe feefeffe
3ffff8f0:  feefeffe feefeffe feefeffe feefeffe
3ffff900:  feefeffe feefeffe feefeffe feefeffe
3ffff910:  feefeffe feefeffe feefeffe feefeffe
3ffff920:  feefeffe feefeffe feefeffe feefeffe
3ffff930:  feefeffe feefeffe feefeffe feefeffe
3ffff940:  feefeffe feefeffe feefeffe feefeffe
3ffff950:  feefeffe feefeffe feefeffe feefeffe
3ffff960:  feefeffe feefeffe feefeffe feefeffe
3ffff970:  feefeffe feefeffe feefeffe feefeffe
3ffff980:  feefeffe feefeffe feefeffe feefeffe
3ffff990:  feefeffe feefeffe feefeffe feefeffe
3ffff9a0:  feefeffe feefeffe feefeffe feefeffe
3ffff9b0:  feefeffe feefeffe feefeffe feefeffe
3ffff9c0:  feefeffe feefeffe feefeffe feefeffe
3ffff9d0:  feefeffe feefeffe feefeffe feefeffe
3ffff9e0:  feefeffe feefeffe feefeffe feefeffe
3ffff9f0:  feefeffe feefeffe feefeffe feefeffe
3ffffa00:  feefeffe feefeffe feefeffe feefeffe
3ffffa10:  feefeffe feefeffe feefeffe feefeffe
3ffffa20:  feefeffe feefeffe feefeffe feefeffe
3ffffa30:  feefeffe feefeffe feefeffe feefeffe
3ffffa40:  feefeffe feefeffe feefeffe feefeffe
3ffffa50:  feefeffe feefeffe feefeffe feefeffe
3ffffa60:  feefeffe feefeffe feefeffe feefeffe
3ffffa70:  feefeffe feefeffe feefeffe feefeffe
3ffffa80:  feefeffe feefeffe feefeffe feefeffe
3ffffa90:  feefeffe feefeffe feefeffe feefeffe
3ffffaa0:  feefeffe feefeffe feefeffe feefeffe
3ffffab0:  feefeffe feefeffe feefeffe feefeffe
3ffffac0:  feefeffe feefeffe feefeffe feefeffe
3ffffad0:  feefeffe feefeffe feefeffe feefeffe
3ffffae0:  00000000 00000000 00000020 401013da
3ffffaf0:  3ffe9680 401047c0 3fff0154 000000fd
3ffffb00:  00000001 401039e3 3ffed800 3ffed848
3ffffb10:  40103e46 00000000 00000020 401013da
3ffffb20:  00000005 00000000 00000020 401013da
3ffffb30:  00000000 00000000 00000020 401013da
3ffffb40:  3ffe9680 401047c0 3fff0154 00000000
3ffffb50:  00000001 401039e3 3ffed800 401022c2
3ffffb60:  40103e46 00000000 00000000 401022c2
3ffffb70:  40103729 00040000 7fffffff 00000000
3ffffb80:  00000022 40103726 00040000 00000000
3ffffb90:  00000000 00000000 0000001f 401050bd
3ffffba0:  4000050c 00080000 00002000 4000050c
3ffffbb0:  40229838 00000030 0000001b ffffffff
3ffffbc0:  40229836 00000023 00000020 00000005
3ffffbd0:  3ffe95b4 00000020 3ffe951c 00000000
3ffffbe0:  00000005 3ffe9514 00000001 3ffecdc8
3ffffbf0:  3ffef854 00000001 3fff0a30 00000030
3ffffc00:  3ffe9685 401047db 3ffed110 3ffee2a8
3ffffc10:  00000000 00000000 00000020 000000fa
3ffffc20:  00000004 00000000 00000020 401013da
3ffffc30:  3ffe9684 401047a6 3ffecdc8 401013da
3ffffc40:  00000005 00000000 00000020 401013da
3ffffc50:  3ffe9685 401047db 3ffed110 3ffed800
3ffffc60:  401020f1 3ffed110 3ffed800 000000f4
3ffffc70:  00007fff 06460509 402296d3 00000001
3ffffc80:  ffffffff 00000000 3ffe97d1 00000008
3ffffc90:  40229722 3ffecdf0 3ffef854 00000001
3ffffca0:  4022982e 3ffecdf0 3ffef854 3ffecdf0
3ffffcb0:  00000005 00000005 00000008 3fff1250
3ffffcc0:  3ffe9682 402287df 3ffecdf0 3fff0a68
3ffffcd0:  00000000 4021ba8b 3ffee2a8 00000022
3ffffce0:  00000000 00000002 00000000 3ffecdf0
3ffffcf0:  3fff126a 40104e63 3fff0a68 3ffeffe4
3ffffd00:  3fff1234 0000002f 00013880 00000001
3ffffd10:  00000004 4020ddc9 3ffef218 3ffeffe4
3ffffd20:  3fff126a 0000023f 00000001 3ffeef98
3ffffd30:  00000000 3ffeef98 4216cccd 00000000
3ffffd40:  3ffef644 3ffef60c 3fff1234 4020e04b
3ffffd50:  4000dd1f 3ffef60c 3fff1234 4020e43c
3ffffd60:  3ffef490 4bc6a7f0 12b020c4 00000000
3ffffd70:  00000000 00000000 4bc6a7f0 3ffef494
3ffffd80:  3ffef644 00000000 3ffef60c 40215b14
3ffffd90:  00000000 3ffee968 019672ab 00000000
3ffffda0:  00000000 3fff1234 3ffef1b8 00000000
3ffffdb0:  3ffee990 3ffef1b8 3ffe8510 3fff1234
3ffffdc0:  3fff1234 3fff0868 3ffef60c 40215d18
3ffffdd0:  40100000 3ffeef98 00000000 401001cd
3ffffde0:  3fff1278 3fff0868 3ffef60c 40216730
3ffffdf0:  3fff0864 402171fc 00000010 401007f4
3ffffe00:  00000014 3fff0864 000000ff 00000000
3ffffe10:  00000006 3ffef580 00000284 401007f4
3ffffe20:  00000055 00000218 3fff0864 3fff0864
3ffffe30:  3fff07fc 3ffef60c 3fff0b2c 40216778
3ffffe40:  00000000 4bc6a7f0 676c8b43 00000000
3ffffe50:  00000000 00000000 4bc6a7f0 00000000
3ffffe60:  3ffef1dc 000003ef 4010014c 0002bef4
3ffffe70:  00000000 4bc6a7f0 79db22d0 00000000
3ffffe80:  032cca97 00000000 3ffe8510 00000000
3ffffe90:  00000003 3ffe9238 40205d54 3fffefa0
3ffffea0:  00000003 00000000 3fff05c4 40203a0b
3ffffeb0:  0328466c 00000000 3fff05c4 40203a5d
3ffffec0:  00000002 3ffe9235 40205d54 4216cccd
3ffffed0:  3fffff50 00000000 3fffff50 40205355
3ffffee0:  3ffe9238 00000000 3fff05c4 40203a5d
3ffffef0:  0000000d 00000000 7ff80000 402055ca
3fffff00:  00000002 00000000 3fffff50 40205355
3fffff10:  3ffe9235 429ab852 3fffff50 4216cccd
3fffff20:  7fc00000 429ab852 3fffff50 40205714
3fffff30:  7fc00000 429ab852 3fffff50 40205731
3fffff40:  7fc00000 429ab852 7fc00000 402029d7
3fffff50:  40206478 00000000 00001388 4020e7a7
3fffff60:  00000000 3fff05c4 00000000 00000000
3fffff70:  00000000 3fff0a8c 0000007f 00000000
3fffff80:  7fc00000 41c9999a 3ffef0f8 402025a4
3fffff90:  00000000 00000000 00000001 3ffef160
3fffffa0:  3fffdad0 00000000 3ffef130 40205e00
<<<stack<<<

 ets Jan  8 2013,rst cause:2, boot mode:(1,6)

 ets Jan  8 2013,rst cause:4, boot mode:(1,6)

wdt reset

EspExceptionDecoder stack trace:

don't use the String class

u mean that i change string brightness to int?

http://hacking.majenko.co.uk/the-evils-of-arduino-strings

thanks that was new for me, but wouldnt that just make WDT reset come later? i want to eliminate it as much as possible

try the esp exception decoder, it will tell you what line of your code crashes.

But this WDT reset problem appeared just recently after i added more code and functionality to my site. ahhh, "more code", yes, it's always "more code" that does it ... any chance you can share what code you added that broke your ESP?

i have installed the decoder and posted the stack trace here, there are errors on more lines not just single one.. most of them are memory issues if i understand them correctly


text:
Powering an Arduino directly from a motor driver (DRV8825) or external power source?
Hello people from StackExchange,
I'm new to Arduino and driving stepper motors in general; please excuse me for my limited knowledge on the subject. I've been doing research for a few hours already, looking into powering stepper motors and the Arduino, though I've gotten conflicting information regarding my problem.
My problem, or well question if you will, is as follows:
The circuit I need, simplified, contains an Arduino, a stepper motor driver (DRV8825), a NEMA17 5kg.cm stepper motor and a 12V battery pack (yet to be decided what kind of pack, though it will be 12V). Do I need another, lower voltage, battery pack?
After looking into how to power stepper motors using the Arduino online, I found several sites instructing me how to do so. All of the sites had the same circuit I would use, only the motor was different. Here is one of the circuits:

As you can see, it only has a single power supply (with capacitor to catch voltage peaks). I understand most of the circuit, though one question remains: why exactly is there only one power supply being shown here, is it because the Arduino can get its power from the driver? (You can see the pin descriptions in the second image below) Or do they simply not show the (5v) power supply for the Arduino?
The thing I want to know, is whether this circuit would function without an external power supply for the Arduino or not? And if not, would connecting the Arduino to the power supply via the VIN pin work? That would be nice, as it would offer a simple way of fixing the problem instead of getting a separate power source. Connecting the Arduino through USB wouldn't work for my project, as it can't have any wires coming from it. It needs to be completely mobile.
For comparison, here is a circuit that does show the Arduino with an external power source:

I'm a first years mechanical engineering student, hence my little knowledge on Arduino's and stepper motors.
Thanks in advance.

The Arduino and the motor driver still need to have a 5V power supply.
In the circuit, the motor driver is supplied with 5V logic power from the Arduino board - the Arduinos power source has been omitted.
You can use your motor power supply to input power to the Arduino via the VIN pin or the DC jack and use the onboard 5V regulator for that task, but beware of the regulators heat dissipation at 12V.

why exactly is there only one power supply being shown here, is it because the Arduino can get its power from the driver?

No. It is assumed that you will provide the power to the Arduino yourself - either through the USB connection to the computer, or through the barrel jack.

The thing I want to know, is whether this circuit would function without an external power supply for the Arduino or not?

No. The Arduino requires power to be provided.

And if not, would connecting the Arduino to the power supply via the VIN pin work?

Yes, but it's not ideal.  At 12V the power wasted by the on-board linear voltage regulator will be proportionally high.  As long as all that is being powered is the Arduino itself that shouldn't be too bad, but if you try to draw any significant current either out of the 5V pin or through multiple IO pins (for example to drive lots of LEDs) then it will overheat and potentially shut down.
A more ideal arrangement would be to connect a 5V switching regulator to the 12V battery and use that to power the Arduino either through the 5V pin or the USB connector. Personally, I use cheap UBEC modules from RC model suppliers. They are small, low-cost, and very easy to wire up.


text:
Getting weird characters from Arduino
My arduino is connected to ultrasonic sensor and I am trying to read the value from it. When I tried running "tail -f > /dev/ttyACM0" my arduino is sending some weird characters that I am not able to decode

Did you ssty?

What is that means? Can you explain?

In addition to the answers, be sure to "Serial.println(sensorValue, DEC)", to be sure it's printed decimally and not as individual incorrect ASCII characters

Have you looked at the data coming back in hex or binary? That might make it easier to see if the source is possibly using a different character set page in Unicode. The graphics symbols are not standard ASCII. I saw a mention of the source being Audi so it's possible the character set is a European one.

This other post looks similiar: (https://arduino.stackexchange.com/questions/12617/arduino-serial-monitor-shows-strange-ascii-characters?rq=1) and I have to ask if you have any documentation or reference on the sensor. It's just as likely to be sending data in binary, do you have any reason to suspect that it should be ASCII values?

It would seem you failed to configure the port on the Linux side. By
default, it is configured to who-knows-what baud rate, and to a “cooked”
mode where the data is preprocessed by the kernel driver. You want
instead to set it to the correct baud rate and to “raw” mode. The stty
(meaning, “set terminal”) command does this:
stty -F /dev/ttyACM0 raw 9600

Replace 9600 with whatever baud rate your Arduino is using.
If you Arduino program attempts to read the serial port, it will see the
echo of the characters it sends. In that case you probably want to
disable this echo also:
stty -F /dev/ttyACM0 raw -echo 9600

I have done this with the right baudrate but no change in the output

@SanthoshkumarSundararaj: There may be something wrong with the sending code. Try to replace it with something trivial, like void setup(){Serial.begin(9600);} void loop(){Serial.println("Hello!");}.

Unfortunately I cant change the code. I am working with AUDI autonomous car. So it has four arduino micro connected with 5 ultrasonic sensors. My task is to establish the connection and get the values from arduino.

Most likely this is incorrect baud rate. You can try with a program dedicated to serial ports, my personal choice is picocom but it can by minicom or any other:
$ picocom -b 9600 /dev/ttyACM0

The -b parameter is used for specifying the baud rate, depending on the sketch it can be something else than 9600, the most common ones are: 9600, 14400, 19200, 28800, 38400, 57600
Another solution is to configure the /dev/ttyACM0 with correct baud rate using stty:
stty -F /dev/ttyACM0 9600 cs8 -cstopb -parenb

This will configure the serial port to 9600 bps, 8 bits, 1 stop bit, no parity, and allow the tail command to read it correctly, if the communication parameters match what the arduino is sending

I have tried both but still it is giving the same strange characters


text:
Can the 'Adafruit Non-Latching Mini Relay FeatherWing' be used with an Arduino microcontroller such as an Arduino Mega 2560?
Can this relay found here:
https://www.adafruit.com/product/2895
Be used with an Arduino Mega? The description given seems to specify that you should hook it up to their dedicated 'Featherwing Board' but it's the only relay available on their site. Looking at the pins it has it seems it should hook up to an Arduino with no problems. Has anyone here had the chance to use this relay with an Arduino microcontroller? I asked them about this on their forum but I haven't received a reply yet.
PS: I want to use it to connect a 'Strobe Siren 12VDC' and the relay I was looking to get is out of stock at my local shop.
https://store.nerokas.co.ke/index.php?route=product/product&product_id=1398
https://store.nerokas.co.ke/index.php?route=product/product&product_id=1679

Yes.
There's not a lot more to be said really.
It's a relay, and they provide a MOSFET and associated circuitry to drive it cleanly.
Just connect power and ground to the Arduino, along with the "Signal" pin to the GPIO pin of your choice, and away you go.
Note that the relay is a 3.3V relay, so you must power it by the 3.3V pin, not the 5V pin.

That relay draws way, WAAAY more power than the 3.3V line on and Arduino puts out. The data sheet says it draws 100-200mW. That's just the relay. The logic circuitry and LED will probably draw 20-50mW more than that. As I recall the 3.3V line on most Arduinos only provides ≈50mA of 3.3V, which is completely inadequate.

@DuncanC That was the case 10 years ago. Back then the 3.3V pin was powered by the internal 3.3V regulator in the FT232R chip. That is no longer the case, and hasn't been for many years (since the Uno R2). Now it has a dedicated 3.3V regulator that can provide a few hundred mA (LP2985 - 150mA).

At 3.3V, 200mW is 60mA. The LED has a 1k resistor, so would be around 3mA.  That's 63mA - less than half what the regulator can provide.

Ok, that relay quotes 200 mW, not 200mA. That isn't quite as bad as I thought. However, the Arduino store says the current limit of the 3.3V line is 50mA, and that's still over the limit: https://store.arduino.cc/usa/arduino-uno-rev3

To quote the specs tab on that page: "DC Current for 3.3V Pin 50 mA". And that's from the page for the current Rev3 board.

@DuncanC Never trust anything Arduino say.  Those specs are for the original R1 UNO and have never been updated.

@DuncanC If you don't believe me, then get the schematic from the same page, find the 3.3V regulator, and then download the datasheet from TI.

@DuncanC The hardware design branch of Arduino is "ok". The website management team are a bunch of useless faggots. You just have to look at some of their "tutorials" to realise that...

The regulator might be up to more current than that, but I don't think they are adequately heat-sinked for that. (In fact I don't think the regulators on Arduinos have any heat sinks at all.)

@DuncanC The LP2985 is perfectly fine running at those levels. It's only got to drop down from 5V (less sometimes if it's powered from USB...), and they can handle that kind of curent quite well. I use them all the time.

@DuncanC By the way - you don't heat sink an SOT23. They're designed to heat sink just through the pins. They don't generate enough heat to need more than that.

@DuncanC By the way II - Microchip do a pin-compatible device that is rated to 300mA. They rate it double because the input voltage is limited to 5V (or just over) unlike the 16V of the LP2985.

That is a 3.3V device. you'll need to give it a separate 3.3V power input, and it needs much higher current at 3.3V than the Arduino can supply.
I don't know if you can feed it a 5V logic signal or not. (If it needs 3.3 V control signals as well, and it's current needs are modest you could step down the voltage from an Arduino 5V digital output to 3.3 with a simple voltage divider circuit.)
You'd be better off getting a 5V relay. If you do a Google search on "Arduino Relay" you'll find tons of them. You can get 1 relay, 2 relay, 4 relay, and more on a board. Many have optical isolation to make sure the relay coils don't add noise to the logic lines.
In general it's a good idea to use a separate power supply for the relay, or at least use a power supply with plenty of current to spare, and add filtering capacitors between the 5V rail and ground right next to both the relay and the Arduino. These capacitors serve to filter out variations in voltage as the relay coils are powered on and off.
(Even "digital" relays draw a large amount of current from their power source when they first turn on, and abruptly stop drawing current when they turn off, which introduces a lot of noise on the power line. "Naked" relays need "flyback diodes" to avoid reverse currents that will destroy transistors, but the "digital ready" relays I'm talking about have those built in.)
Here is one such relay I found from Googling "Arduino relay".
https://vetco.net/products/single-relay-module-for-arduino?gclid=EAIaIQobChMI8Ye70K-e4QIVBkSGCh2EBgEiEAQYAyABEgIxpvD_BwE


text:
client.connect() failing unless I ping my ESP
[EDIT] it seems like this has to do with my laptop's firewall settings rather than anything wrong with the ESP8266 [/EDIT]
I have a webserver on my laptop. When I do this on my ESP8266 (after the wifi has been connected)
while(!client.connect(laptop,port)) {
   Serial.println("Connecting...");
   delay(1000);
}

It loops forever. However, if I manually ping my ESP from my laptop, I initially get this
Pinging 192.168.1.7 with 32 bytes of data:
Request timed out.
Reply from 192.168.1.7: bytes=32 time=4ms TTL=255

And as soon as this happens, the ESP gets connected to the laptop, and all works fine.
So it seems to me like the client.connect is preventing the ESP from even registering to the network, and the pinging is somehow waking it up.

what if you ping something else instead?

tried that - it doesn't do anything

oh wait, you're right - if I ping something else, even an IP that does not exist, the ESP suddenly connects. OK this means there's something dodgy going on on my computer. Going to check if this happens with another device.

Just tried running the server from a raspberry PI, the ESP connects without trouble. There must be some firewall thing or something going on my laptop. Will check and revert

could not find the source of the issue - firewall is definitely off. I should try to get hold of another laptop (as opposed to PI) to check

Hmm, have you tried using a port above 1024? I once had trouble with that, but it's just an idea...

oh yeah that's one of the first thing I thought about, but I was already using 3000. I tried 8000, just in case that would help - no diff. And I should mention that when I ran the script on my PI, I had to do sudo otherwise it would not work.


text:
Control 2 ESC with a potentiometer with arduino
I have 2 ESC (electronic speed controller) which control these brushless motors: Hobbyking Donkey ST3511 Brushless Motor
I would like to make them work with a poentiometer, under arduino.
I have a program but it only works with one engine. Here is the program :
#include <Servo.h>//Using servo library to control ESC

Servo esc;
Servo esc2;
//Creating a servo class with name as esc

void setup()

{

esc.attach(9); //Specify the esc signal pin,Here as D8

esc.writeMicroseconds(1000); //initialize the signal to 1000

Serial.begin(9600);

esc2.attach(9); //Specify the esc signal pin,Here as D8

esc2.writeMicroseconds(1000); //initialize the signal to 1000

Serial.begin(9600);

}

void loop()

{

int val; //Creating a variable val

val= analogRead(A0); //Read input from analog pin a0 and store in val

val= map(val, 0, 1023,1000,2000); //mapping val to minimum and maximum(Change if needed)

esc.writeMicroseconds(val); //using val as the signal to esc
esc2.writeMicroseconds(val);
}

I did not find help on the internet, thank you in advance.

In your code you are attaching both esc objects to the same pin ( pin 9 ). That cannot be, what you indented. Use two different pins.

Oh, and you are beginning the Serial interface also twice. CopyPaste problem?

I'd say yes, it's a copy-paste problem as in the OP just duplicated the code without understanding what needs to be changed.

You need to assign 2 different hardware pins to your two different speed controllers. Do you want one pot (potentiometer) to control both motors, or a separate pot for each motor?

If you want one potentiometer to handle BOTH ESCs' speed, you could use this code:
//Using servo library to control ESC
#include <Servo.h>

//Starting the servos
Servo esc1;
Servo esc2;

void setup() {
    esc1.attach(9); // Use a PWM pin to the Servo, in this case 9
    esc1.writeMicroseconds(1000); //initialize the signal to 1000
    esc2.attach(10); // Pick another PWM to the other, in this case 10
    esc2.writeMicroseconds(1000); //initialize the signal to 1000

    Serial.begin(9600);
}

void loop() {
    int val; //Creating a variable val
    val= analogRead(A0); //Read input from analog pin a0 and store in val
    val= map(val, 0, 1023,1000,2000); //mapping val to minimum and maximum(analogRead's goes from 0-1023 and analogWrite's goes from 0-255, check your servo's specs)
    esc1.writeMicroseconds(val); // write to the first ESC
    esc2.writeMicroseconds(val); // write to the second ESC
    delay(100); // We usually set a small delay to avoid excessive readings or over-heating, but thats optional...
}

If you need to use two potentiometers, one for each ESC, then you would have to start another variable to read the 2nd pot value and use it to write on the 2nd ESC, simple as that! :)


text:
Is Ticker.h really safe to use?
I have this code
#include <Ticker.h>  //Ticker Library
Ticker blinker;
/* ... */

//blinker.attach(1, []() { digitalWrite(LED,!digitalRead(LED)); }
while(!client.connect(laptop,port)) {
   Serial.println("Connecting...");
   delay(1000);
}

Which works fine, tries connecting, then eventually connects.
If I uncomment the line attaching to this 'blinker' Ticker, then I get a crash right after the first 'Connecting...' print. When I look at the stack trace, it mentions that the crash happens during the delay(1000) in my while loop (which is presumably the moment when the program yields and the blinker can do some work)
Is there anything I can do to make this timer work better?

What library is the blinker object from? Where does the Timer.h, from the title` come into play?

I was confused - I meant Ticker.h - I updated the code to make it more apparent - apologies for that

What's the boot message after the crash? You'll have to set the terminal speed to 74400 to see it. It'll look something like ets Jan  8 2013,rst cause:2, boot mode:(3,6) - the rst cause: number is the most important thing.

Couldn't get the rst cause thing for some reason...

Update: the original question mentioned timers, so this answer is for a hardware timer interrupt handler. It doesn't apply to Ticker, which is what the question is now about.
The callback that you attach to blinker will be called as an interrupt handler, so it's important to make sure it's already loaded into executable instruction memory (iRAM) on the ESP8266. When you pass anonymous function inline to blinker.attach() it won't tagged to be stored in iRAM.
Try this instead:
void ICACHE_RAM_ATTR blinker_handler(){
    digitalWrite(LED,!(digitalRead(LED)));  //Toggle LED Pin
}

...

blinker.attach(1, blinker_handler);

ICACHE_RAM_ATTR tells the system to keep the code in the instruction RAM. There's not a lot of iRAM (32Kbytes) so you don't want to do this too often, but it's important for interrupt handlers (another reason to keep them short and sweet).

oh that's very useful, thanks. I've used Tickers in other cases, and it seemed to work fine even though I was attaching callbacks to them instead of IRAM (which I had no idea about). I will try your suggestion.

What's the purpose of timer1_write(600000); please?

@MarkSmith I believe that was in the original example before it was updated.

@joelhoro with the update - now that we're talking about Ticker, not a timer - I don't think this is the right answer. I thought you were talking about a hardware timer's interrupt handler - this would be correct for that. But I'm sure Ticker's callback doesn't run as an interrupt handler. I'll edit the answer to point that out but I think there's going to be a different solution.


text:
Powering Uno with 9v battery makes it "freak out"
I encountered an odd problem with my Uno, it works completely fine through USB on the PC or when powered by a power bank, but as soon as I connect it on a 9v battery it just freaks out. I have a relay connected to it that is connected to a switch, works fine, but on the battery it keeps turning on and off super fast, like so fast that the relay doesn't even show it's doing it, I noticed because of the noise it makes. I even tried to slow it down with a delay but nothing changed.
Anyone have any idea why the battery would make this happen?

Use the battery in a smoke detector, but not for an arduino project. It is too weak for a relay.

Not enough current available from the battery, relays take quite a lot. As soon as the relay tries to switch the voltage drops and the Uno resets due to brownout (low voltage)

It's actually not just the relay that takes up a lot of current. The 9V-port on your arduino uno is actually not meant for a 9V block, because the arduino uno needs a higher current than your 9V block can deliver. You can put 6 1.5V battery cells (AA batteries) in series, they will deliver the current you'll need.

Really? I'm able to run my Arduino-based power control box just fine from a 9V battery, and it has a LCD display, piezo buzzer, 2 temp/humidity sensors, LEDs, a motion sensor, and various other components. (It drives power relays, but those are only powered when it's plugged into mains power.) Granted, the LCD backlight starts to dim when the 9V battery starts to run out of gas, and eventually the voltage droops to the point where it doesn't work any more, but it will run the whole project for a couple of hours.

Doesn't a fresh 9V have about 500mAh capacity? Should be enough for an hour if the Arduino draws 1/2 amp, which is enough for quite a few low power accessories on top of the Arduino itself.

@DuncanC the problem is that if someone grabs just any 9v battery, it might not be fresh and it might not be a good brand. The main problem is the maximum current that a 9v battery can deliver. A 9v battery with lithium is 1200mAh, that would be better (for a few hours).


text:
Cannot upload to Robotdyn Mega 2560 PRO MINI?
I get this error trying to upload avrdude: stk500v2_ReceiveMessage(): timeout
It is Robotdyn Mega 2560 PRO MINI and a Robotdyn CH340 which I have connected like this:
I installed the CH340 drivers from here https://sparks.gogo.co.nz/ch340.html and I can see it in the device manager.
Connecting the Mega 2560 Pro Mini lights up the L and On LED but when pressing upload (testing with simple examples as Blink) I get the error and neither RX or TX lights up.
I have tried everything I can think of. What am I doing wrong?
I have confirmed that it is connected to the correct COM-port and I use these settings:
Board: Arduino/Genuino Mega or Mega 2560
Processor: ATMega2560 (Mega 2560)

I have also tried many different USB-cables, short and long, and USB 2.0 and USB 3.0 ports. I use Windows 10 64-bit.

why is the pin header not soldered to board?

It is now, took the picture before

@Juraj this is not the same error message?

but the same troubleshooting

I now have the adapter and it has swapped RX TX labels, so must be wired RX to RX, TX to TX

Try placing a 100nf capacitor on RST. That is usually required on an FTDI programmer.
See Edgar's post - https://arduino.stackexchange.com/users/47431/edgar


text:
Cannot give battery through USB cable
I just make a simple circuit with uno and breadboard ,that connected 4 LED and 4 IR sensor. The arduino program is simple that makes the light on or off with the determination of IR sensors .
However my computer cannot find the USB COM when it connects the 5v and GND.
Hence, I plug out the 5v and GND that connect to the breadboard .The computer can recognize COM 4 then . I successfully upload the program after this .
Now , when I connect the computer and UNO to give battery to UNO , no battery passed (because the computer cannot detect the USB COM) .The lights of IR sensor aren't on .How to tackle the problem?
It failed to  give battery with external battery too unless I plug out the 5v and GND
This is my simple program:
int irPin1 = 2;
int ledPin1 = 13;
int irPin2 = 3;
int ledPin2 = 11;
int irPin3 = 4;
int ledPin3 = 9;
int irPin4 = 5;
int ledPin4 = 7;
int serialSpeed = 9600;

void setup() {
  // put your setup code here, to run once:
  pinMode(irPin1,INPUT);
  pinMode(irPin2,INPUT);
  pinMode(irPin3,INPUT);
  pinMode(irPin4,INPUT);
  pinMode(ledPin1,OUTPUT);
  pinMode(ledPin2,OUTPUT);
  pinMode(ledPin3,OUTPUT);
  pinMode(ledPin4,OUTPUT);
  Serial.begin(serialSpeed);
}

void loop() {
  // put your main code here, to run repeatedly:
  int reading1 = digitalRead(irPin1);
  int reading2 = digitalRead(irPin2);
  int reading3 = digitalRead(irPin3);
  int reading4 = digitalRead(irPin4);
  digitalWrite(ledPin1,reading1);
  digitalWrite(ledPin2,reading2);
  digitalWrite(ledPin3,reading3);
  digitalWrite(ledPin4,reading4);
  String output = "{\"1\":" + (String)reading1 + ",\"2\":" + (String)reading2 + ",\"3\":" + (String)reading3 + ",\"4\":" + (String)reading4 + "}";
//  String output = "{\"" + (String)reading1 + "\",\"" + (String)reading2 + "\",\"" + (String)reading3 + "\",\"" + (String)reading4 + "\"}";
  Serial.println(output);
  delay(100);
}

My Arduino circuit:
UNO 5v to breadboard 5v
UNO GND to breadboard GND
1st set: IR :5v GND
from breadboard , pin from UNO
2nd set: IR :5v GND from breadboard ,
pin from UNO
3rd set: IR :5v GND from breadboard , pin from UNO
4th
set: IR :5v GND from breadboard , pin from UNO

Can you upload an actual picture of your breadboard? Think you have short.

@Zunzullaalagaty see update ! My Arduino circuit:
UNO 5v to breadboard 5v UNO GND to breadboard GND
1st set: IR :5v GND from breadboard , pin from UNO
2nd set: IR :5v GND from breadboard , pin from UNO
3rd set: IR :5v GND from breadboard , pin from UNO
4th set: IR :5v GND from breadboard , pin from UNO

on a first glance it seems fine actually. What I see from your picture is that your arduino doesnt light up. If you press the reset button, does any led light up? If not, try disconnecting sensors and leds until it starts to light up when pressing the reset button

@Zunzullaalagaty The power is fine after I plug one of the IR out  .What just happened? what is short circuit actually

It's a circuit where the current can pass without any consumer. It seems like you have that IR sensors plugged in wrong? Or maybe made a mistake in the code about the Input and Output for the IR sensor.

What voltage does your battery have? If you feed into Vin and got a short, the voltage regulator or the diode might be blown due to the high current. This would block the battery power to get in anymore. Please be carefull with building the circuit. A short can destroy the Arduino, but also the USB port of your PC, if connected to it.


text:
Parsing array of an object in a library constructor
I am trying to develop an Arduino library that consists out of two classes. I want 'WayPointStack' to store an array of 'WPCommand', but I can't get it to work.
WayPointStack.h
#ifndef WayPointStack_h
#define WayPointStack_h

#include "Arduino.h"
#include "WPCommand.h"

class WayPointStack
{
  public:
    WayPointStack();
    WayPointStack(WPCommand* wp);
    WPCommand GetNextWP();
    WPCommand GetWP(int i);
    void AddWP(int target, int time);
    int SetWPPointer(int i);
    int GetLength();
  private:
    WPCommand* _wp;
    int pointer;
    int length;
};
#endif

WPCommand.h
#ifndef WPCommand_h
#define WPCommand_h

#include "Arduino.h"

class WPCommand
{
  public:
    WPCommand(int target, int time );
    WPCommand();
    int GetTarget();
    int GetTime();
    int LEFT;
    int RIGHT;
    int FORWARD;
    int BACKWARD;
    int STOP;
    int END;
  private:
    int _target;
    int _time;
};

#endif

Parts of WaypointStack.cpp
#include "Arduino.h"
#include "WayPointStack.h"
#include "WPCommand.h"

#define arrSize 100

WayPointStack::WayPointStack()
{
  _wp = new WPCommand[arrSize]; // should be enough, heap blabla
  length = 0;
  pointer = 0;
}

WayPointStack::WayPointStack(WPCommand[] wp)
{
    _wp = new WPCommand[arrSize]; // should be enough, heap blabla
    for (int i = 0; i < sizeof(wp), i++){
        _wp[i] = wp[i];
    }
    length = sizeof(wp);
    pointer = 0;
}

I'm pretty sure I'm doing something wrong with the pointers, but I don't know how to fix it. The first two errors are
WayPointStack.cpp:24:42: error: expected ',' or '...' before 'wp'
WayPointStack::WayPointStack(WPCommand[] wp)

and
WayPointStack.cpp:27:29: error: 'wp' was not declared in this scope
for (int i = 0; i < sizeof(wp), i++){

I obviously have to use a pointer. This is all I know, so far.
Has someone an idea?

Arduino is not Java it is based on C++. Check the syntax for array/vectors and passing parameters by reference. Also check who to determine the number of elements in a vector. Sizeof() is the number of bytes.

This is a C++, not Arduino question and should be asked on Stack Overflow.
In C/C++ the [] must be on variable name, not on type. WPCommand wp[] (it is the same as WPCommand* wp).
sizeof return size in bytes, not element count. send length as parameter
Dynamic memory allocation in MCU is not a good thing. You can have in WayPointStack
WPCommand _wp[arrSize]

Thank you. It reduced the error amount dramatically.


text:
switching two relays without delay using millis
I have an Arduino-uno and two relays. Each relay has two switch on for two seconds at regular intervals.
total loop time relay 1 and relay2 is 1800 seconds.
relay 1 - 2 on,360 off,2 on,600 off,2 on,430 off,2on,402 off.
relay 2 - 12 off, 2 on, 358 off, 2 on, 606 off, 2 on, 478 off, 2 on, 338 off.
Can somebody help me on a code for this please.

Do both have a total time of 1800, then I suppose they have to be in sync. You can start by making an array or struct with the numbers. The blink without delay example runs at 1 second interval. Use that 1 second interval to check the array or struct. Have you use the 'enum' before to define numbers to actions?

When the blink without delay is used, the first second is one second after the arduino has turned on. The pinMode for relay 1 sets it off. That means after turning on the arduino or after a reset, relay 1 is off for one second. Is that okay? Assuming that a HIGH turns the relay on and a LOW output turns the relay off.

Yes, both the relays have a total time of 1800 seconds, and normally HIGH turns the relay off, and LOW turns the relay on. I tried already a few time to work with the blink without delay code (on advise), but I don't know how to code the on and off times in the code - Jerry.

What about arrays, enum and struct? are you familiar with those?

Instead of asking me all those questions, which I can only answer partly, because my little knowledge in this field. Is it not easier for someone to give me a workable sketch, so that I can try and play with it? Or is this to difficult or not possible?

this is a typical application for Blink Without Delay

// Turn leds on and off at certain times.
//
// When the digital output pin is HIGH, then the relay is off.
// When the digital output pin is LOW, then the relay is on.

enum actionEnum {
  RELAY1_ON,
  RELAY1_OFF,
  RELAY2_ON,
  RELAY2_OFF,
};

struct tableStruct {
  unsigned int time;
  actionEnum action;
} const table[] = {
  { 0, RELAY1_ON},
  { 2, RELAY1_OFF},
  { 2 + 360, RELAY1_ON},
  { 2 + 360 + 2, RELAY1_OFF},
  { 2 + 360 + 2 + 600, RELAY1_ON},
  { 2 + 360 + 2 + 600 + 2, RELAY1_OFF},
  { 2 + 360 + 2 + 600 + 2 + 430, RELAY1_ON},
  { 2 + 360 + 2 + 600 + 2 + 430 + 2, RELAY1_OFF},
  // remaining 402 for a total of 1800
  { 0, RELAY2_OFF},         // not needed, it is already off
  { 12, RELAY2_ON},
  { 12 + 2, RELAY2_OFF},
  { 12 + 2 + 358, RELAY2_ON},
  { 12 + 2 + 358 + 2, RELAY2_OFF},
  { 12 + 2 + 358 + 2 + 606, RELAY2_ON},
  { 12 + 2 + 358 + 2 + 606 + 2, RELAY2_OFF},
  { 12 + 2 + 358 + 2 + 606 + 2 + 478, RELAY2_ON},
  { 12 + 2 + 358 + 2 + 606 + 2 + 478 + 2, RELAY2_OFF},
  // remaining 338  for a total of 1800
};

const unsigned int totalTime = 1800;  // total amount of seconds for sequence
unsigned int seconds;

unsigned long previousMillis;
const unsigned long interval = 1000;  // 1000 ms is one second

const int relay1Pin = 2;
const int relay2Pin = 3;

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

  // The relay is off when the pin is high.
  // Turn output high before setting the pinMode.
  // Then the output changes from a floating pin to high,
  // and the relais will not be activated.
  digitalWrite(relay1Pin, HIGH);
  pinMode(relay1Pin, OUTPUT);
  digitalWrite(relay2Pin, HIGH);
  pinMode(relay2Pin, OUTPUT);
}

void loop() {
  // A one-second timer with millis
  if (millis() - previousMillis >= interval) {
    previousMillis += interval;

    // Scan table
    for (int i = 0; i < int(sizeof(table) / sizeof(tableStruct)); i++) {
      if (table[i].time == seconds) {
        switch (table[i].action) {
          case RELAY1_ON:
            Serial.println("Relay 1 on");
            digitalWrite(relay1Pin, LOW);  // low = relay on
            break;
          case RELAY1_OFF:
            Serial.println("Relay 1 off");
            digitalWrite(relay1Pin, HIGH);  // high = relay off
            break;
          case RELAY2_ON:
            Serial.println("Relay 2 on");
            digitalWrite(relay2Pin, LOW);   // low = relay on
            break;
          case RELAY2_OFF:
            Serial.println("Relay 2 off");
            digitalWrite(relay2Pin, HIGH);  // high = relay off
            break;
          default:
            Serial.println("Error, a bug in the sketch");
            break;
        }
      }
    }

    seconds++;
    if (seconds >= totalTime) {
      seconds = 0;
    }
  }
}

Thank you very much. I am going to try this, and I will let you know.

@Jerry I have tested it and confirmed that it is working according to the information that you gave.

Working perfect, thank you very much, Jerry.

@Jerry, I'm glad it is working for you. Do you see how it works? Any command can be put into the table. For example: "measure the temperature" or "make a beep". In the one-second-millis timer, the whole table is scanned to check if something needs to be done.


text:
Measuring Amplitude/Frequency of sound
I need to read an analog signal at about 500-1000Hz for at least 5 seconds.
I've a battery powered microphone wired into an analog and ground pin on my arduino and am trying to measure the frequency (and amplitude) of sound coming from a rijke tube
To accurately represent the sound waves I need to take samples with a frequency at least twice that of the sound I'm studying, hence the frequency above. I plan to next do FFT to find the frequencies associated with the sound sample
Having stripped down every other part of my code, I could still only get at the most 107 readings a second, as shown below
#define VOLT_CAL 269
#define CURRENT_CAL 60
unsigned long time;

EnergyMonitor emon1;             // Create an instance

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

  Serial.println("CLEARDATE");
  Serial.println("LABEL, DATE, TIME,Wall Voltage,Wall Current, Mic Voltage, Time Elapsed");
}

void loop()
{
  int sensorValue = analogRead(A4);

   time = millis();

  Serial.print(sensorValue);
  Serial.print(",");
  Serial.println(time); //prints time since program started
}

can anyone tell me what I'm doing wrong/how I can increase the sample rate?
I've also tried to use a for loop to take my readings first, only printing them at the end but also maxed out at only 100 readings a second with the next attempt.
I've read also about preclocking, but the example codes were too complex for me to understand. A starting point in this direction would also be very much appreciated.

Serial prints at 9600 baud slow your loop down

i've tried it with 115200 and even 250000, it didnt get faster

500 samples per second for 5 seconds with 16 bit integer = 5000 byte. The arduino uno has 2000 byte sram. Do you have another arduino board?

no...is it really complex to get maybe 400Hz? it doesn't need to be integers, i just need to read analog

Use a hardware timer, for example https://arduino.stackexchange.com/questions/50045/uniform-timing-when-using-arduino-for-data-acquisition .  Data sampling rates up to 100 kHz are possible!

Also, Arduino UNO can be used but to greatly increase the timing accuracy consider substituting the 16 MHz ceramic resonator for a crystal.

The arduino uno with the normal arduino functions can do 4000 samples per second. When using the registers of the microcontroller a higher sample rate is possible. Set the baudrate to 1000000, use only this in the loop (nothing else): Serial.println(analogRead(A4));

@Jot, there is a problem with your suggestion ..... there is no timing information in the resulting data

@zueses, is there a reason why you are using an arduino for this project?

it's just a starting suggestion from my professor, is it unreliable?

You need to do the engineering part first before doing a project like this. That is calculate possible sample rate, storage size, etc, given the resources. By doing this you can see that the given requirements cannot be met with an Arduino Uno. This might be what your professor actually wants you to do instead of implementing on an Arduino Uno just to find out it was not possible.


text:
Arduino nano power 5V or 12V and LED strip 2812B 5V
I would like to know a little more about Arduino inputs and outputs.
I'm doing a small project which is composed of 1 LED strip with 40 LED's.
Can't find any definitely information about Arduino +  LED strip.
At the moment all of this doesn't work correctly and I guess the reason is bad power connection .
The main power is from USB. So all of this in a car. I have ~12v (+2 or -2 Volts ) and then Voltage regulator to 5V with USB output and then cable connecting 5V through USB Arduino . Then I took wires from VIN ( pin number 30 ) to LED strip +5V ( which is basically main fuse on the strip ) and then GND to ground of led strip and of course DIN to DIN like it should be.
Conclusion is - the led strip won't work normally and colors are not proper .
How should I do connect ?
If I will take off the voltage regulator then main fuse from the car ~12V connect to the VIN (it will be a main arduino power) . GND - GND pin obviously.  - and then again from same point ~12V of car will connect to voltage regulator 12V to 5V and that 5V must be with LED strip FUSE +5V ?
Is it will be correct way ?
And one more question, shall I put between "main fuse from the car ~12V connect to the VIN (it will be a main arduino power)" - Voltage regulator 12V to 5V ? is it necessary ?
Thanks for you answers guys, hope you will help me with this.
I'm going to read same questions and answer with this any way. Will wait your answers too :)

Does your strip need 12V or 5V? This isn't clear from the question. Also: won't work normally and colors are not proper what does this mean? What do you actually observer?

the 5 V pin is to power 5 V devices

5V needs , I mean on the end of strip she is flashing and shows another colors

hm... okay then, I have to put regulator 12V to 5V before VIN connection. Actually Arduino nano tech specs says VIN can be connected from 7~16V . Thats why Im asking about it .

okay, so.. I should connect through voltage regulator to VIN (comes 5V ) and GND . - this is arduino power . (or I can connect same USB - only for arduino power. ) and then I must take 5V on LED strip from a car voltage regulator , not from arduino VIN pin . Is in it ?  What about Ground for LED strip.?  Should I take it from Arduino GND to LED strip GND or never mind I can take GND from the car ?

How many LEDs do you have on that strip? Power loss (=> turned into heat) is (Vin - Vout)*I for linear regulators. So if you want to drive 64 full on LEDs, you'll need big ass regulator with huge heat sink. Or you can use switching DC-DC regulator.

I have just 40 :) slightly less :) ~800mA needed if every led takes ~20mA . and 5V.

WS2812 leds can use upto 60mA each (20mA for Red, 20mA for Green, and 20mA for Blue). So that's 2.4A of max current. In that case the voltage regulator would have to burn away 17Watts of power. No way it's able to do that.

You can't draw ≈800mA from the 5V pin on an Arduino that's being powered through USB.  There is a fuse that limits TOTAL current drawn from USB to 500mA. Exceed that and it will shut down.

The main power is from USB. So all of this in a car. I have ~12v (+2 or -2 Volts ) and then Voltage regulator to 5V with USB output and then cable connecting 5V through USB Arduino .

Good. That is the best way of powering an Arduino in a car. Use a phone charger is best.

Then I took wires from VIN ( pin number 30 ) to LED strip +5V

There's no such thing as a "pin number 30" on an Arduino Uno. However, powering anything from VIN when you are supplying power into the Arduino through USB is very bad.
Basically, the current has to flow backwards through the onboard regulator to get to the VIN pin - and the regulator really doesn't like that.
Instead, you should be connecting your LED strip to the 5V pin of the Arduino so it is connected direct to the 5V USB power.
Note, however, that the USB power has a limit of 500mA.  This is not a limit of the supply - it is a limit imposed by a 500mA PTC fuse on the Arduino that will shut off the current if more than 500mA is drawn.  It would be far better if you could cut the USB cable and take the 5V and GND wires and directly connect them to both the Arduino's 5V and GND pins, and the LED strip's 5V and GND connections.  That will then mean that the LEDs are taking their power directly from the power supply, not from the Arduino.

That`s Great!! Thank you so much!! I feel better now!

40 LEDs can draw up to 60mA x 40 = 2.4A (2400mA). Make sure you have a large enough current source if you are planning on using full white on all LEDs.
Arduino regulators are not selected to support 2.4A. 600-700 mA tops, and then only if the voltage to the barrel jack is 7.5V max. With 12V, much less current is supported as the regulator gets hot dissipating (12V - 5V) x current draw as excess heat.
And 500mA for USB as noted due to PTC fuse.


text:
1st LED turn ON when 1st button is pressed and other LEDs remaining OFF
I have 2 LEDs and 2 buttons. What I want to code is when first button pressed the 1st LED turn on (stay on for 5 seconds) and 2nd LED remain off, and same if 2nd button pressed the 2nd LED turn on and 1st LED remain off. I want the processing reset after 5 seconds.
Here is my work, what it does now is 1st LED turn on when I press 1st button, but the 2nd button and 2nd LED still can press and light up right after. I want the 2nd button deactivate when 1st button pressed for 5 seconds.
Please give me basic program because I am new to this.
int pinButton_1 = 8; //the pin where we connect the button
int pinButton_2 = 9;
int LED_1 = 1; //the pin we connect the LED
int LED_2 = 2;
void setup() {
  pinMode(pinButton_1, INPUT); //set the button pin as INPUT
  pinMode(pinButton_2, INPUT);
  pinMode(LED_1, OUTPUT); //set the LED pin as OUTPUT
  pinMode(LED_2, OUTPUT);
}

void loop() {
  int stateButton_1 = digitalRead(pinButton_1); //read the state of the button
  int stateButton_2 = digitalRead(pinButton_2); //read the state of the button
  if(stateButton_1 == 1) { //if is pressed
     digitalWrite(LED_1, HIGH); //LED_1 on
     digitalWrite(LED_2, LOW); //LED_2 off
     delay(50);
  }
     if (stateButton_2 == 1) {
      digitalWrite(LED_1, LOW);
      digitalWrite(LED_2, HIGH);
      delay(50);
     }
  }

First of all you have not implemented a stay on time of 5seconds delay(5000); but only 50ms delay(50);.
Second, you are not really switching of your LED's if no further button is pressed.
Change your loop() to the following, I guess this will help you to start your next steps into getting familiar with your code:
    void loop() {
      int stateButton_1 = digitalRead(pinButton_1); //read the state of the Button_1
      if(stateButton_1 == 1) {      //if Button_1 is pressed
         digitalWrite(LED_1, HIGH); //LED_1 on
         digitalWrite(LED_2, LOW);  //LED_2 off
         delay(5000);
      }
      digitalWrite(LED_1, LOW); //Switch off LED_1

      int stateButton_2 = digitalRead(pinButton_2); //read the state of the button 2
      if (stateButton_2 == 1) {
         digitalWrite(LED_1, LOW);
         digitalWrite(LED_2, HIGH);
         delay(5000);
      }
      digitalWrite(LED_2, LOW); //Switch off LED_2
    }

Hint: Using delay() is often not a good construct, better to do it with millis(), but this means some more changes. For the start in your case delay() will do, but check out what here in different Questions/answers is already written about delay() vs. millis()

thank you for your help, I really appreciated