text:
I'm looking for a way to emulate addressable LED strip using LED diodes in a custom arrangement
What I want to achieve is, I want to use my own LED pin diodes, customly place them into my sculpture and animate them. This is as I understand quite straightforward. The problem is the amount of wiring . I would want them to connect one another in series with addresses, rather then each led needing a direct data from the controller on a separate cable.
I know that addressable LEDs use a single data line through the all lights, eliminating the need to connect each led physically to the controller to get data. Is there any way to build a similar system with a bus-like structure, I believe it is possible. And if so, how? What would I need? I guess I need individual small chips for each LED, but I don't know if that's the case or even if it is how so.
I consider myself quite a newbie in electronics-arduino or LEDs, however I'm actively looking into it and researching.

You could buy the same chips, that are on the addressable LED strips, the WS2811 or its siblings.

If you connct ordinary LEDs to the same wire, the will behave relativly the same. You would have no chance to control them separately. If you use a PWM controller like WS2811, or 3 PWM pins from an Arduino to control one single LED you can control the LEDs separately. But from the amount of work and money you have to invest, this is only adviceble, if you can not exchange the currently used LEDs for the project/scupture. If possible use prebuild WS2811 LEDs like neopixels.

you can buy addressable LEDs that have leads

You can buy individually addressable LEDs like the ones in LED strips. If you are fairly new to electronics I would not try to build your own serial LED controller.

I think this may be the safest option. I'm trying to understand the size limitations and the cost of these kind of systems. It turns out that there are even small pin LEDs  with IC that are addressable! Thank you


text:
Cant make the second 74HC595 to start counting
I'm doing my first project with Arduino, however I got in a block and cannot figure out what I am doing wrong.
This project is 'simple'. It's that Stranger Thing's Wall.
However, I want to use the 74HC595 to leave pins free on the arduino for maybe expand and do something else with that too, so, I tried doing the arduino tutorial (https://www.arduino.cc/en/Tutorial/Foundations/ShiftOut)
So my current schematic is this one below

My code, however, is kind of a frankenstein. I used the shiftOut from the tutorials, however I must confess I do not know how it works (And I think its where the error may lie). I do know VBA and Python, but I know nothing of C (Or whichever this language is)
    //Pin connected to ST_CP of 74HC595
#define latchPin 5
//Pin connected to SH_CP of 74HC595
#define clockPin 7
////Pin connected to DS of 74HC595
#define dataPin 6
String text;                                                    //Variável do tipo string que receberá o texto
void setup() {
  Serial.begin(9600);                                           //Velocidade de comunicação
  for (int i = 2; i < 7; i++) {
    pinMode(i, OUTPUT);                                   //Declarando o pino como saída
  }
  Serial.println("Iniciando");
  inicializationEffect();                                       //Chamada da Função responsável pelo efeito inicial
  //basicTest();
}
void loop() {

  receiveText();                                               //Chamada da função responsável por receber o texto digitado
}
//Função que recebe o texto diitado
void receiveText() {
  while (Serial.available() > 0) {                              //Verifica se existe alguma informação na Serial
    char c = Serial.read();                                     //atribui cada caractere a variável c que é do tipo char
    if (c != '\n') text.concat(c) ;                              //verifica se a variável do tipo char recebeu uma quebra de linha que indica o fim da palavra ou frase e concatena todos os caracteres na String text
    delay(10);                                                  //aguarda 10 milissegundos
  }
  if (text.length() > 0) {                                      //verifica se a string text tem tamanho maior que 0
    text.toUpperCase();                                       //transforma tudo que estiver na string text para maiúsculo
    if (text[0] == '#'){
      waveEffect();
    }else {
      executeEffect(text);                                        //chama a função executeEffect passando a string text como parâmetro
    }
  }
  text = "";                                                    //limpa a string text
}
//Função responsável por ativar linha que recebe como parâmetro o número da linha
void lineActivation(int line, int keepalive) {
  if (keepalive == 0) {
    for (int i = 2; i <= 4; i++) {
      digitalWrite(i, LOW);
    }
  }
    digitalWrite(line+1, HIGH);                               //coloca a linha 1 em estado lógico alto
}

void activateLetter(char letter, int on, int off) {
  int lt;
  lt = (((int)letter - 64) % 9);
  if (((int)letter - 64) > 8) {
    lt = lt + 1;
  }
  if (on) {
    callCol(1<<lt-1);
    delay(on);                                                //mantém o pino em nível lógico alto durante o tempo que foi determinado no parâmetro da função
  }
  if (off) {
    callCol(0);
    delay(off);                                               //mantém o pino em nível lógico baixo durante o tempo que foi determinado no parâmetro da função
  }

}

void callCol(int col){
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, 0);
  shiftOut(dataPin, clockPin, col);
  digitalWrite(latchPin, HIGH);

}
void executeEffect(String text) {
  for (int i = 0; i < text.length(); i++) {
    if (text[i] == ' ') {
      delay(1000);
    } else if ((int)text[i] < 65 or (int)text[i] > 90) {
    } else {
      lineActivation(int(((int)text[i] - 64) / 9) + 1, 0);
      activateLetter(text[i], 1000, 200);
    }
  }
}

void inicializationEffect() {
  for (int i = 1; i < 27; i++) {
    lineActivation(int(i / 9) + 1, 0);                          //ativa a linha
    activateLetter(char(64 + i), 1000, 10);                   //ativa a letra
  }
}
void waveEffect() {
  for (int i = 1; i < 4; i++) {
    lineActivation(i, 1);                          //ativa a linha
  }
  for (int i = 1; i < 10; i++) {
    activateLetter(char(72 + i), 100, 0);
  }

  for (int i = 1; i < 10; i++) {
    activateLetter(char(72 + i), 0, 100);
  }
  for (int i = 1; i < 4; i++) {
    lineActivation(i, 1);                          //ativa a linha
  }
}

void basicTest() {
  lineActivation(2,1);
    for (int i = 0; 1 < 500; i++) {
    callCol(255-i);
    delay(100);
    }

}

void shiftOut(int myDataPin, int myClockPin, byte myDataOut) {
// This shifts 8 bits out MSB first,
//on the rising edge of the clock,
//clock idles low
//internal function setup
int i=0;
int pinState;
pinMode(myClockPin, OUTPUT);
pinMode(myDataPin, OUTPUT);
//clear everything out just in case to
//prepare shift register for bit shifting
digitalWrite(myDataPin, 0);
digitalWrite(myClockPin, 0);
//for each bit in the byte myDataOut�
//NOTICE THAT WE ARE COUNTING DOWN in our for loop
//This means that %00000001 or "1" will go through such
//that it will be pin Q0 that lights.
for (i=7; i>=0; i--)  {
digitalWrite(myClockPin, 0);
//if the value passed to myDataOut and a bitmask result
// true then... so if we are at i=6 and our value is
// %11010100 it would the code compares it to %01000000
// and proceeds to set pinState to 1.
if ( myDataOut & (1<<i) ) {
pinState= 1;
}
else {
pinState= 0;
}
//Sets the pin to HIGH or LOW depending on pinState
digitalWrite(myDataPin, pinState);
//register shifts bits on upstroke of clock pin
digitalWrite(myClockPin, 1);
//zero the data pin after shift to prevent bleed through
digitalWrite(myDataPin, 0);
}
//stop shifting
digitalWrite(myClockPin, 0);
}

If I understood right (Which I may not) theoretically, when I send a value over 255, it should "overflow" to the next 74HC595, which would be used to light the ninth column.

why shiftOut(dataPin, clockPin, 0);?

To ensure its clear, however I removed that line for the solution I posted

where did you get that idea?

I mean, I was wrong. But the point was to always set the Binary value to 0 before setting it to the correct value. Just as a Failsafe, however the more I deal with this I realize the less I know. It doesnt need a failsafe, right?

Solved using https://arduino.stackexchange.com/a/17093/37827
By removing the custom shiftOut function and changing my
shiftOut(dataPin, clockPin, 0);
shiftOut(dataPin, clockPin, col);

with
shiftOut(dataPin, clockPin, MSBFIRST, highByte(col));
shiftOut(dataPin, clockPin, MSBFIRST, lowByte(col));

Works like a charm
PS: Feel free to suggest something else, but this way it fixed my problem

source: Stack Exchange

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

sort: votes


text:
Arduino Serial Monitor displaying weird characters and changes spelling

I am recieving the following in my serial monitor. There is a mix of wierd characters then the spelling changes for words once it gets repeated. I don't know why its doing this. my esp01 chip uses 115200 baud rate and the program is 115200 baud rate as well. What is going on.
#include <SoftwareSerial.h>

#define TIMEOUT 5000 // mS
#define LED 5

SoftwareSerial mySerial(7, 6); // RX, TX

const int button = 11;
int button_state = 0;

void setup()
{
  pinMode(LED, OUTPUT);
  pinMode(button, INPUT);

  Serial.begin(115200);
  mySerial.begin(115200);

  SendCommand("AT+RST", "Ready");

  delay(5000);

  SendCommand("AT+CWMODE=3", "OK");
  SendCommand("AT+CIFSR", "OK");
  SendCommand("AT+CIPMUX=1", "OK");
  SendCommand("AT+CIPSERVER=1,80", "OK");
}

void loop() {
  button_state = digitalRead(button);
  mySerial.println(button_state);

  if (button_state == HIGH) {
    SendCommand("AT+CIPSEND=0,23", "OK");

    delay(250);

    mySerial.println("
Button was pressed!
");

    delay(250);

    SendCommand("AT+CIPCLOSE=0", "OK");
  }

  String IncomingString = "";
  boolean StringReady = false;

  while (mySerial.available()) {
    IncomingString = mySerial.readString();
    StringReady = true;
  }

  if (StringReady) {
    Serial.println("Received String: " + IncomingString);

    if (IncomingString.indexOf("LED=ON") != -1) {
      digitalWrite(LED, HIGH);
    }

    if (IncomingString.indexOf("LED=OFF") != -1) {
      digitalWrite(LED, LOW);
    }
  }
}

boolean SendCommand(String cmd, String ack) {
  mySerial.println(cmd); // Send "AT+" command to module

  if (!echoFind(ack)) // timed out waiting for ack string
    return true; // ack blank or ack found
}

boolean echoFind(String keyword) {
  byte current_char = 0;
  byte keyword_length = keyword.length();
  long deadline = millis() + TIMEOUT;

  while (millis() < deadline) {
    if (mySerial.available()) {
      char ch = mySerial.read();
      Serial.write(ch);

      if (ch == keyword[current_char])
        if (++current_char == keyword_length) {
          Serial.println();
          return true;
        }
    }
  }

  return false; // Timed out
}

SoftwareSerial doesn't work reliably at 115200 baud. use 9600 baud. do not forget to change the baud rate at AT firmware side

Try adding:
void setup()
{
  pinMode(LED, OUTPUT);
  pinMode(button, INPUT);

  Serial.begin(115200);
  while(!Serial){}       // Loop until USB is ready

  mySerial.begin(115200);

It will unblock once the USB port is ready.

Your code for the most part looks ok. Your symptoms indicate a Baud mismatch or the receiver is not getting all of the bits. Try doing without the delay's, even reducing them may help. Note when in a delay the processor is committed and cannot do anything else.  See if that helps. 115000 baud is quit hot for the Arduino and software serial. Maybe you can slow things down a little and see if that helps.

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


text:
Error in uploading sketch to digispark attiny85 board
I'm trying to use Digispark attiny85 board and running into issues uploading the sketch.
The drivers are correctly installed. I have followed this page as a reference.
Below the sketch and the error message.

Thanks for any help

"LAB C Student 8" is part of your installation and work path. It contains spaces. I can not see the flasher call (launcher) complete but it seems as the path is not quoted in "..." so the complete path is separated in many arguments and thus the flasher can not find the hex file to upload. It's just a guess. But the tool calls in the output above do not fail and the paths are escaped therein.

please remove the picture of text and replace it with the actual text ... some of us are unable to view images ... it is also easier to test your code

You cant have spaces in your name. I made a second account named 'test' to run the code


text:
Upload s sketch to a 5v Pro-Micro board as 3.3V by mistake
I have 2 types of Pro-Micro(as shown here), both 5v, micro-usb, which worked as expected, until, accidentally were flashed as 3.3v using the Arduino IDE.
At first I thought that the fact it stoped working right after, has nothing to do with that error, but since again, did the same mistake, I understand that this is no coincidence.
After doing so, boards seemed to be powered on ( leds are ON ), but are not found under port in the Arduino IDE.
Are they really can be destroyed by such an error ?

Holding RST and GND pins after re-connecting USB, showed it on port menu.
needed another such holding, prior to upload.
All good now.

I had the same issue with a promicro wired in to a button box, before i found out that you need to upload a sketch....I know...I`m a noob, I was trying to rename my button boxes board to a Sparkfun board but I think i had 3.3v 8mhz selected instead of 5v 16mhz, as a result my board was not detected under comm ports and gave a driver error, given that...with my board at least there is only an 8 second delay in which you have to select the correct comm device and then upload a sketch, I shortened the process by opening IDE and selecting the board type and left IDE with a black sketch, of coarse this does not allow the board to be detected as a usb device but it fixes the comm port issue, instead of using a fiddly wire jumper i just used a small screw driver to jump the gnd and reset contacts and quickly selected the boards comm port in IDE then upload  with out a delay, by the time IDE actually recognizes a device you actually have closer to 3-4 seconds to react....but its doable.


text:
Rc switch library display received values only one times using serial monitor
I use Rc switch library to transmit and receive data. It works fine.
The part that sends the data is as follows :
#include <Arduino.h>
#include <RCSwitch.h>

RCSwitch transmitter = RCSwitch();

void setup()
{
    Serial.begin(9600);
    transmitter.enableTransmit(10);
}

void loop()
{
    /* Send data in binary */

    // Go right
    transmitter.send("010101010101010100000011");
    delay(1000);

    // Go left
    transmitter.send("010101010101010100001100");
    delay(1000);
}

And the receiving part is like this:
#include <RCSwitch.h>

RCSwitch receiver = RCSwitch();
int rightLED = 4;
int leftLED = 7;
unsigned long receivedValue;
unsigned long goRight = 5592323;
unsigned long goLeft = 5592332;

void setup()
{
    Serial.begin(9600);
    receiver.enableReceive(0); // Receiver on interrupt 0
    pinMode(rightLED, OUTPUT);
    pinMode(leftLED, OUTPUT);
}

void moveRight()
{
    Serial.println("I'm going right");
}

void moveLeft()
{
    Serial.println("I'm going left");
}

void loop()
{
    if (receiver.available())
    {
        receivedValue = receiver.getReceivedValue();
        if (receivedValue == goRight)
        {
            moveRight();
        }
        if (receivedValue == goLeft)
        {
            moveLeft();
        }
        receiver.resetAvailable();
    }
}

The problem is, when I open a serial monitor and look the output of the received values moveRight and moveLeft functions are called multiple times.
I'm going right
I'm going right
I'm going right
I'm going right
I'm going left
I'm going left
I'm going left
I'm going left
I'm going right
I'm going right
I'm going right
I'm going right

What kind of change should I do in the receiver part so that moveRight and moveLeft functions are called only once.
I'm going right
I'm going left
I'm going right

You can save the previous received value, and only print if it is different from what you just received.
Something like this:
// near the top
const int rightLED = 4;
const int leftLED = 7;
const unsigned long goRight = 5592323;
const unsigned long goLeft = 5592332;

// to hold the state
unsigned long previousValue = 0;

// ...

// loop code
void loop()
{
  if (receiver.available())
  {
    unsigned long receivedValue = receiver.getReceivedValue();
    if (receivedValue != previousValue) {
      // something changed
      if (receivedValue == goRight)
      {
        moveRight();
      }
      if (receivedValue == goLeft)
      {
        moveLeft();
      }
      // remember the current value
      previousValue = receivedValue;
    }
    receiver.resetAvailable();
  }
}

Depending on you application, you might also want to store the time of the last received value, and compare that. Otherwise, when pressing the same button twice, it will ignore the last press.

Old post, I know but I have to add to it.  The statement   "transmitter.enableTransmit(10);" causes the RCSwitch library to send the message 10 times.  You are receiving 4 messages; you should be receiving 10. I have found that when using "receiver.available()" I also get about half of what is expected. Just a hunch, but I think the "receiver.available()" is getting every other message.  The RCSwitch library may have a dwell period after a message is received that holds the receiver in suspense causing every other message to be lost.  "Serial.begin(9600)" also is a bit slow, but I think the buffer can handel it.
The attached image shows my transmitter power consumption.  You can see that 10 messages are sent in about 200 mS.  Your delay(1000) leaves plenty of time for completion of all messages received.


text:
How to get the sizeof array of structs
I'm trying to make a use of a relay module,
I want a clear way to configure and control my relay module
I've defined the struct and filled it with some info about id, pin number, title, and relay state
I can't loop with for in the array of controls, because I can't get the sizeof the array right
typedef struct{
  int id;
  int pin;
  String title;
  bool state;
}  SwitchControl;

SwitchControl controls[2] = {
  {1, 22, "Switch 01", 1},
  {2, 23, "Switch 02", 0},
};

for(int i=0; i<sizeof(controls) - 1; i++){
}

thanks

This is really a C++ question more than anything.  In case you're wondering the Arduino source preprocessing has no effect on this.

Try (sizeof(controls)/sizeof(controls[0]) or better (sizeof(controls)/sizeof(SwitchControl))

for (const auto &e: controls) {   or std::size if you happen to have that.   still seems like a C++ question really.

I would code a const right above, eg. MAX_CONTROL, which keeps later code clean and (I think) faster, as C++ doesn't have to calc anything each time it's used.

@dandavis, A constant expression like one involving the division of the result of two sizeof operators will be evaluated at compile time in pretty much any compiler.  Or at least those made after about 1992 or so.

To make it generic, you simply divide the sizeof the array by the sizeof the type:
for(int i=0; i<sizeof(controls)/sizeof(SwitchControl); i++){
}

Then you can later change the items if the array, or the structure and the code will be the same.

A more generic way (usable in future cases) is:
// number of items in an array
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))

Now you can use ARRAY_SIZE (the_array) in your code like this:
for(int i=0; i<ARRAY_SIZE (controls); i++){
}

The above works in C as well as C++.

The more C++ way of doing it is to use a template like this:
// number of items in an array
template< typename T, size_t N > size_t ArraySize (T (&) [N]){ return N; }

Now ArraySize(the_array) returns the number of elements in the array:
for(int i=0; i< ArraySize (controls); i++){
}

The "Arduino language" is C++ with some initial pre-processing. For all intents and purposes any tutorial on C++ will help you with Arduino programming (except that the Standard Template Library (STL) is not included by default).

I don't know why you were subtracting 1 in your posted code. Did you not want to iterate through the whole array?

sizeof(controls) returns the size, in bytes, of the entire object which is not what you want.  You want the number of elements.
I'll point out that since you're statically allocating this as:

SwitchControl controls[2]

The size you are looking for is always going to be 2.  So just use 2 in your for loop like:

for(int i=0; i<2; i++)

The number of elements is 2 for now. But the point in using sizeof() with statical allocation is, that you can easily add more elements to the array, without changing all the for loops in your code. It is highly probable, that the shown code of the OP is just a test code, and that the final code might have more elements and the number of elements might change between different iterations of the code. While your suggestion works, it is not a good tip to do so.

I think you're reading a lot more into this question that is currently there.  Yes, you are correct but sometimes you need to walk before you can run.


text:
Separate control unit from LEDs
I am using an adapter (12 VDC, 2A) and I want to be able to power an LED strip with it plus the control circuit.
The problem is that the Atmega328 reboots, but when I only power up the LED strip with that adapter and power the control circuit with an independent 5 V adapter everything seems to be alright.
I can't do that in real world; I need to ude the same adapter.
I attached a picture of what I am doing right now. Please help me fix this.
I am using a 7805 regulator to reduce the 12 V to 5 V.

How much current does the LED strip use?

What do you mean by "the Atmega328 reboots"? When exactly does it reset? And have you tried putting a big capacitor between the power lines of the LED strip? Changing the strip state also influences the power draw. When the strip suddenly draws way more power, the power supply might produce a short dip in voltage, which you can smooth out with that capacitor

And what kind of strip are you using? How exactly are you controlling it? Please show your circuit.

what exactly is your question? ... you did not actually ask one ... more than one question could be asked

easy: you need a dc adapter with more amps.

Why not use the barrel input connector and input 12VDC there, the filtering etc on the board will help. Also as dandavis stated you need a bigger power supply or remove about 1/2 of your LEDs.

what barrel input?

Without the "Schematic" (picture) how would you answer it, they were not when I answered it. You might also look at the dates.


text:
Compensate weight due to acceleration (load cells)
I'm trying to make a weighing scale that works in a lift. I'm using load cells to measure the weight, let's say it's F. Then I use that weight F and g which I know is 9,81 m/s2 to calculate the mass of the object like this:
F = m·g <=> m = F/g
This works when the lift is in rest (or when moving at a constant speed), but when it accelerates the weight F increases and because of that the mass also increases. Is there a way to compensate this weight(/extra force) due to acceleration?

Maybe measure the effective g with an accelerometer?

Of cause it's possible. g is an acceleration. If the lift accelerates, you have to measure the acceleration, with an accelerometer. Then use the found acceleration instead of g in the formula. The resulting acceleration, you measure, is g plus(up)/minus(down) the lifts accelleration.

only weight when the lift isn't moving. 2. Have a separate load cell with a known weight on top, so you can calculate the acceleration. 3. Average the values over time, to average out the error due to the short moment of acceleration (most lifts only accelerate/decelerate for a few seconds).  4. Ignore it all together as lift only accelerate at 1m/s², giving you, at most, a 10% error is weight, which might be acceptable depending on the application.

The force due to acceleration is: F = m*a
So to calculate the weight while accelerating the formula is:
F = mg + ma or F = m(g + a)
Note, of course, that a can be positive or negative depending on whether the elevator is accelerating or decelerating.
The trick here is to know what "a" is.  The best approach is probably to get an accelerometer and use its reading in your calculations.
By the way, the mass is always a constant here.  It does not change, in Newtonian Physics at least, due to acceleration.

Note that an accelerometer actually measures a+g.

You could measure the total acceleration (g + lift acceleration) with an accelerometer, and use that value in your calculation instead of 9.81m/s2. If the measured value is 0, sound an alarm.
Or, assuming the elevator only accelerates/decelerates for short periodes only (say, less than 2s) during a "trip", you could make a series of measurements in a loop at, say, every 0.5s.
When you get, say, 5 measurements that are the same, or very close to each other, you know acceleration = 0 and you can average those 5 measurements to get the desired result.
Values may vary depending on the lift, and the measurements will be slow in coming.


text:
Own type definition using a struct does not name a type
I need to initialize several buttons and LEDs connected to my Arduino. To store data related to an individual button or LED, I decided to define my own data type using two different structs. One for a button and another one for a LED.
As I need to configure some GPIOs and other peripherals after instantiating each button/LED, I implemented a small factory function to get a clean interface and combine the required steps for instantiating and initialization.
Defining my own button_t type works as expected. The compiler does not throw any errors. However, I tried to implement the same approach for led_t type upon the compiler states the following error:

example:25:1: error: 'led_t' does not name a type
led_t ledFactory(uint8_t pinNumber)
^~~~~
exit status 1 'led_t' does not name a type

My example code looks like this:
#include <Arduino.h>
#include <stdint.h>

struct button_t
{
    const uint8_t pin;
    uint8_t currentState;
    uint8_t lastState;
    uint32_t lastDebounceTime;
};

button_t buttonFactory(uint8_t pinNumber)
{
    button_t btn = {pinNumber, 0, 0, 0};
    // setting some MCU registers here
    return btn;
};

struct led_t
{
    const uint8_t pin;
    const uint8_t state;
};

led_t ledFactory(uint8_t pinNumber)
{
    led_t led = {pinNumber, 0};
    // setting some MCU registers here
    return led;
};

void setup()
{
}

void loop()
{
}

This is a bug in the Arduino IDE: when converting your .ino file to a
.cpp file, it added a declaration for the function ledFactory()
before the declaration of the type led_t.
As it appears to be adding those declarations right before the first
function of your sketch, a simple workaround is to put all your type
definitions before your functions.

@albert, if your curious to see this mangling for yourself, check "compilation" for "Show verbose ... " in File/Preferences.  You should see the full compiler command-line immediately before the error message.  It will reference some /sketch/your_sketch_name.ino.cpp file.  There you see the result of the build process's manipulation of your .ino file into the .cpp file it ultimately tries to compile.  And for your code, under IDE version 1.8.13 at least, exactly what Edgar described.

First create structure and after create function and after function declaration line c++ is bottom approach.

Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.


text:
Trying to connect to WiFi on ESP32 using credentials from SD card
I am trying to connect to WiFi on an ESP32 using credentials I stored on an SD card. I am able to read and parse the credential and printing them to the serial monitor shows that the SSID and password are correct, but it is not connecting to WiFi. When I hardcode the WiFi credentials it works. What could I be doing wrong?

write a sketch that gets the SSID and password from the SD card and compares them to hardcoded values ... that will tell you if they are the same ... also, print out the length of each of them

It would really help if you showed the code you are using.

thanks i was able to figure it out i had to find a way to convert the string to a const char* this way:  WiFi.begin(ssid.c_str(), pass.c_str());

I use the NVS partition to store NON VOLATILE information.
I use this library: NVS library
You can save like string and restore after reset/off.
Example:
#include <Arduino.h>
#include "ArduinoNvs.h"

void setup() {
    NVS.begin();
    Serial.begin(115200);
    // write to flash
    String set_SSID = "WIFI_name";
    NVS.setString("nvs_wifi_name", set_SSID ); //upload 1 time. after comment this line and upload again **
    // read from flash
    String get_SSID = NVS.getString("nvs_wifi_name");
    Serial.printf("Wifi name stored %s\n", get_SSID);
}

void loop() {}

This doesn't answer the question.


text:
(very new to C) I'm trying to use irsend with what I think is char* but it won't take it. How can I convert it to what it needs?
I'm attempting to use a raspberry pi to send ir codes directly to my arduino to have as simple as a C program as possible. Here's my code I've been tinkering with that leads to errors or not working if I don't specifically hardcode the hex ir signal.
#include <IRremote.h>

char buf[80];

String code = "empty";

int readline(int readch, char *buffer, int len) {
  static int pos = 0;
  int rpos;

  if (readch > 0) {
    switch (readch) {
      case '\r': // Ignore CR
        break;
      case '\n': // Return on new-line
        rpos = pos;
        pos = 0; // Reset position index ready for next time
        return rpos;
      default:
        if (pos < len-1) {
          buffer[pos++] = readch;
          buffer[pos] = 0;
        }
    }
  }
  return 0;
}

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

IRsend irsend;

void loop() {
  if (readline(Serial.read(), buf, 80) > 0) {
    Serial.print("You entered: >");
    //Serial.print(buf);
    //Serial.println("<");
    //irsend.sendNEC((uint32_t) buf, 32);
    String str(buf);
    //irsend.sendNEC((uint32_t) code, 32);
    //irsend.sendNEC(0x210704FB, 32);
    code = buf;
    delay(600);
    //Serial.print((uint32_t) buf, 32);
    Serial.print(code);
    irsend.sendNEC(buf, 32);

  }

I've left my mess on the bottom to illustrate how little I know and what I've tried. I've been trying to figure out what I'm sending it but it doesn't help that serial.print doesn't work like irsend. I'm intending to send hex codes directly and have the arduino blindly plug them into irsend.sendNEC(0x210704FB, 32); which works but when I try to put my own variable in it won't.
Very much appreciate any help! I know it'd be easy for anybody who knows a little C.
irsend.sendNEC(buf, 32); returns:
initializing argument 1 of 'void IRsend::sendNEC(uint32_t, uint8_t, bool)'
void sendNEC(uint32_t data, uint8_t nbits, bool repeat = false);
and irsend.sendNEC((uint32_t) buf, 32); doesn't throw any errors but also does not seem to do anything

when I try to put my own variable ... what variable? ... what is its value?

warning: invalid conversion from 'char*' to 'long unsigned int' [-fpermissive] irsend.sendNEC(buf, 32);

Trying to use buf. irsend.sendNEC(buf, 32); irsend.sendNEC((uint32_t) buf, 32); don't work
added two more sentences to the bottom to help clear anything up

If you are sending HEX values like 0x1234abcd from the Pi to the Arduino to send those as an IR code you first have to interpret that string data as a hexadecimal number.
That's not as simple as just casting the string since, as @timemage says, all you're doing there is casting the address of the character array.
Instead you should use strtoul() to parse the string and give you the equivalent number to what it contains.
strtoul() can convert numbers in a number of different bases, and can even work automatically.  From the Linux man page:

SYNOPSIS
unsigned long int strtoul(const char *nptr, char **endptr, int base);

And later on:

If base is zero or 16, the  string  may then include a "0x" prefix, and the number will be read in base 16; otherwise, a zero base is taken as 10 (decimal) unless the next character is '0', in which case it is taken as 8 (octal).

That means it can automatically parse 0x1234abcd as a hexadecimal number, 12345678 as a decimal number, and 052714 as an octal number (it's important to remember that one so you don't accidentally add a leading zero to a decimal number and have it parsed wrong).
So knowing all that you can now:
uint32_t code = strtoul(buffer, NULL, 0);

and code will contain the contents of buffer represented as an actual numeric variable (assuming the content can be parsed as a number).

It works! Thank you so so much. I think this is the last bit of C that I needed for this project. I appreciate the help so much. It's for remotely controlling my mother's tv while I'm at work. She has dementia and is at the point where she'll give up on the tv and sit in silence all day and her mind comes up with lots of scary thoughts by the time I'm back over to check on her. With regular cable she always winds up watching the news and in her state she feels genuine distraught and fear and spirals downward. You've helped us so so much.

The library you're using and the protocols it implements are not for sending large chunks of data.
The sendNEC function you're using is simply limited to 32 bits per transmission.  You're not going to be able to send an arbitrary length string with it, except by constructing some protocol around it that breaks the string into multiple transmissions of as much as 32 bits at a time.
Without splitting hairs about the language standard and qualifying everything to be perfectly accurate: what you're doing with your (uint32_t) cast is sending the memory address of your string over IR, which is no doubt not what you wanted nor likely particularly useful on the receiving end.
What you appear to want is something closer to IrDA.  That said, you probably could do what you want by calling sendNEC() on each character of your data in the simple case.  Better would be to send 32-bits of the string at a time since there is overhead to each transmission.  But again, these functions and protocols are designed for sending short, infrequent messages.  They were designed to be dirt simple so that they could on be implemented hardware a fraction of the power of a typical Arduino, so that they could be cheap decades ago when when they were inverted.  In an effort to be both simple and at least somewhat reliable, they sacrifice a lot of speed.


text:
ESP32 AsyncWebServer SPIFFS problem loading page
I can load spiff docs, but I get a 404.  Wireless works, IP addressing works and I can load other examples successfully.  This simple image load ino is giving me fits!
#include <WiFi.h>
#include <AsyncTCP.h>
#include <SPIFFS.h>
#include <ESPAsyncWebServer.h>
const char *ssid = "x";
const char *password =  "123456789";
IPAddress staticIP(10,0,0,1); //ESP static ip
IPAddress gateway(0,0,0,0);   //IP Address of your WiFi Router (Gateway)
IPAddress subnet(255, 255, 255, 0);  //Subnet mask

AsyncWebServer server(80);

void setup() {
  Serial.begin(115200);
  WiFi.softAP(ssid, password);

server.on("/", HTTP_GET, [](AsyncWebServerRequest *request)
{request->send(SPIFFS, "/index.htm", "text/html");});

server.on("/image.png", HTTP_GET, [](AsyncWebServerRequest *request)
{request->send(SPIFFS, "/image.png", "image/png");});

server.begin();

}//END setup

void loop()
{
}

<!DOCTYPE HTML>
<html>
<head>
     <meta charset='UTF-8'>
</head>
<body>
     <img src="image.png" alt=" image goes here">
</body>
</html>

I don't have an ESP32 to test with.  Though, I tried to make your code run on an ESP8266, but it's a bit of an effort to validate what is ultimately a wild guess on my part.
And that is: perhaps you have some uppercase letters in your filename such that "/image.png" does not match perfectly and furthermore maybe SPIFFS is case sensitive.  That is, your file could be named Image.png or IMAGE.png and that might matter.
UPDATE:
In my exploring this on the ESP8266, I'd forgotten to execute SPIFFS.begin().  And I see no counterpart to it in your code.
At least one example of ESPAsyncWebServer I've seen does call SPIFFS.begin()
I found that the filenames are case sensitive, again at least on the ESP8266; so that can be a source of problems.
Also checked that if the SPIFFS size is changed through menu selections, I did indeed need to reupload the SPIFFS image.
I know these are different systems; in fact the code I'm using to test doesn't compile for ESP32, but I suspect a lot of the code is shared, and so maybe the problems are as well.

This is it!  Thanks for taking the time.


text:
Detect if MCU is ESP8266 or ESP32
I'm coding a library which handles sleep procedures.
Since I'm using both ESP826 and ESP32, which uses different sleep commands ( and WiFi ), I'm looking for a way to detect the MCU, while NOT using a boolean flag that indicates so.
Guy

#if defined(ESP8266), #if defined(ESP32)

how could you use a boolean flag? the code for esp32 would not compile on esp8266 and vice versa

@Juraj the part that code differs, I need the flag for.

you have in the question "while NOT using a boolean flag that indicates so." so you exclude a not existing option

I take this to mean that you do not want to have to ask the user of the code to configure a boolean flag.
The ESP8266 Arduino package provides -DARDUINO_ARCH_ESP8266 -DESP8266
command-line options these while calling g++.  These effectively #define feature test macros as though they were at the beginning of the source code.
For ESP32 it does likewise with -DARDUINO_ARCH_ESP32 -DESP32
You could perform tests in your code such as:
#if defined (ARDUINO_ARCH_ESP8266)
// do one thing
#elif defined(ESP32)
// do another
#else
#error Architecture unrecognized by this code.
#endif

There are likely also macros like these that are predefined by the xtensa g++ compiler.


text:
Stepper motor driver not working properly
I have a problem. I am following this guide about controlling a NEMA 17 stepper motor: https://www.makerguides.com/a4988-stepper-motor-driver-arduino-tutorial/
I uploaded the code to my arduino uno and powered on everything, but the stepper motor doesn't rotate, except when I put my finger on the metal screw of the a4988 driver. The arduino is powered by a 5v 1A adapter and the a4988 driver is powered with a 12v 2amp adapter.
What is causing this?

have you connected all the grounds?

The "metal screw" is a "trim potentiometer" that is used to set the current used to drive the motor. It sounds like you may be altering the current when you push against it. Try turning it to different angles to see what effect that has on the motor.
Alternatively if it only ever works when you push on it then it could be that you have a faulty potentiometer on your board.

Despite not being able to take it out of the circuit, it is probably safe for you to put a meter across the pot while the board is unpowered.  Certainly worth a try if you get the point of feeling that you need to throw one out.  You can fiddle with it and see if you can notice what Majenko mentions, understanding the results may be skewed by being in circuit. Admittedly, it may be game of twister to get your probes in the right place and manipulate the trimpot the way you want.

Could also be a cracked solder joint connecting the pot to the board. If that's what it is, it could be fixed by heating up the bad solder joint(s) and applying more rosin-core electronics solder to them.

The stepper driver is broken. Bought a new one and everything is working now! But I had to trim the potentiometer indeed!


text:
More than one port available in Arduino IDE in Ubuntu
I'm using Jetson AGX Xavier, and in my Arduino IDE, there are dev/ttyUSB0, dev/ttyUSB1, dev/ttyUSB2, dev/ttyUSB3. I'm sure I connect Arduino in USB0, but I cannot download the code. The device is also correct. Even if I disconnect the Arduino, the available ports are the same.
When I googled it, it turns out the port should be only one. Like, should be only "dev/ttyUSB0". So it really confused me.

You can find what your serial port are with ls -l /dev/serial/by-id

Exactly what Arduino are you using? Is it genuine? Is it a Chinese clone?

If you're sure that you choosed the right port, try reinstalling the Arduino IDE. Maybe this will solve your problem. If it won't, try installing an older IDE.


text:
How to assign ESP8266 access point a hostname that can be resolved by the stations?
I want to assign a hostname to a ESP8266 access point, so that the clients can reach a webserver on this access point without caring about the IP address of the AP. How can that be done?
I tried using WiFi.hostname("something"); but that does not work with AP mode. Can this somehow be done?
UPDATE
Using mDNS seems to work in this AP mode too. However, I am still curious to know if this is possible to access the webserver on the AP using the hostname and not mDNS.

I'm unclear on the distinction being drawn here:

the hostname and not mDNS

mDNS, like DNS, and hostname lists are all things a "resolver" would use to map a "hostname" to an IP address.
If you mean "how do I use DNS instead of mDNS?", you'd need to have your ESP8266 running a DNS server.  And for clients to be aware of it you'd probably have to be running a DHCP server as well.
By the way, the examples list for the ESP8266 Arduino package contains a DNSServer/DNSServer example that appears to do exactly this.  I have just tested it.
This is the exact code I ran out of the ESP8266 Arduino github repo at the tag for the version of the ESP8266 Arduino core I tested it on, 2.7.4.

Well, yes, I would like the ESP AP to be able to resolve the hostnames (including its own hostname, and share it with any station requests this hostname). Thank you for pointing out that the examples include DNS server, I did a quick research and found nothing, now after checking again, I found one example. I am gonna give it a try. Thanks!

@MohammedNoureldin, let me know if it doesn't work.

Thank you for your comment, I got it working using DNS server, I will post a short answer  a bit later. Thank you!

@MohammedNoureldin, good to know.


text:
Device Signature Error uploading to ATMEGA168PA
I keep getting a device signature error and can't program my Atmega168pa chip.
I'm using the board from: https://mcudude.github.io/MiniCore/package_MCUdude_MiniCore_index.json
I've pasted the error below from an attempt to upload a new sketch:
void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

Arduino: 1.8.13 (Linux), Board: "ATmega168, No bootloader, EEPROM retained, 168P / 168PA, BOD disabled, LTO Disabled, Internal 8 MHz"

Sketch uses 412 bytes (2%) of program storage space. Maximum is 16384 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 1015 bytes for local variables. Maximum is 1024 bytes.
/home/rick/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude -C/home/rick/.arduino15/packages/MiniCore/hardware/avr/2.0.7/avrdude.conf -v -patmega168p -cstk500v1 -P/dev/ttyUSB0 -b19200 -Uflash:w:/tmp/arduino_build_51999/sketch_nov15a.ino.with_bootloader.hex:i

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/home/rick/.arduino15/packages/MiniCore/hardware/avr/2.0.7/avrdude.conf"
         User configuration file is "/home/rick/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyUSB0
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
         AVR Part                      : ATmega168P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no        512    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     16384  128    128  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : STK500
         Description     : Atmel STK500 Version 1.x firmware
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x000000 (retrying)

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x000000 (retrying)

An error occurred while uploading the sketch
Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.

avrdude done.  Thank you.

Pictures of my wiring:

I have:

D13 -> (PCINT0/CLKO/ICP1) PB0 [Pin 14]
D12 -> PB4 (MISO/PCINT4) [Pin 18]
D11 -> PB3 (MOSI/OC2A/PCINT3) [Pin 17]
D10 -> (PCINT14/RESET) PC6 [ Pin 1]

I have a 100n capacitor between vcc & gnd and between avcc & gnd. I have a 10 uF capacitor between “Reset” and “Ground” pins on the Arduino. Power is fed via the 5v pin from Arduinio.
I know this nano works (I programmed an ATTiny84 with it before and after my attempts on the Atmega). I've checked pwr & gnd. I'm not 100% sure of the wiring. These chips are new from China so I'm not sure if they are configured for internal or external clock, although I believe they are set to internal by default.

ISP pins are usually all next to each other. That D13 to PB0 is unlikely to be correct. It should be PB5

@KIIV, I just noticed your comment here.  Write it up as an answer and I'll vote my answer for deletion.

The ISP pins are usually all next to each other. The connection D13 to PB0 is unlikely to be correct. It should be connected to PB5.
You can check your connections here: https://www.arduino.cc/en/Tutorial/BuiltInExamples/ArduinoToBreadboard (there is UNO, but pin numbering/wiring is exactly the same as for Nano)
Another possible mistake is burning wrong fuses (with bootloader) for external xtal setting (also mentioned in the article)

The issue was the D13 to PB0 connection, it should have been PB5. After I moved that everything worked perfectly. Thanks!


text:
Infamous white squares for LCD display
I would like to know what I've done wrong. I configured my circuit using the "Hello world tutorial. I got the infamous white square pattern

D7 to pin 2
D6 to pin 3
D5 to pin 4
D4 to pin 5
E to pin 11

My code:
// include the library code:
#include <LiquidCrystal.h>

//LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
LiquidCrystal lcd(2, 3, 4, 5, 11, 12);      // put your pin numbers here

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 0);
  // print the number of seconds since reset:
  lcd.print("hello, world!");
}

The description of the pin map does not seem to match your call legend in the lcd constructor on line.  It is difficult to tell what you have wired without the right angle on the LCD module.  In particular to see RS and RW wiring.  Complete pictures of wiring are helpful.  This would include wiring to the  Arduino, because frankly we all screw this stuff up.

it appears that in the picture you do not have the ground connected

@jsotola, it looked to me that she did, only it was a red lead.

What's connected to V0 on the display? Where's your 10K trimpot so you can adjust the contrast (by changing the voltage between 0 and Vcc) until the "infamous" white squares vanish.

@Dougie contrast is set correctly. The first line should show squares, and the second line is empty, on powerup.

Your picture does not give a clear view of the connections between the Arduino Uno and the LCD module.  However, if we are to follow your description of your connections ...

D7 to pin 2
D6 to pin 3
D5 to pin 4
D4 to pin 5
E to pin 11

... and we assume D7, D6, D5 & D4 are pins on the LCD, then we see that the code is incorrect ...
LiquidCrystal lcd(2, 3, 4, 5, 11, 12);      // put your pin numbers here

... given the LiquidCrystal description here of the syntax of the overloaded (means there are more than one pattern to the passed parameters to the identically named constructor) class ...
Syntax

LiquidCrystal(rs, enable, d4, d5, d6, d7)
LiquidCrystal(rs, rw, enable, d4, d5, d6, d7)
LiquidCrystal(rs, enable, d0, d1, d2, d3, d4, d5, d6, d7)
LiquidCrystal(rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7)

... instead, try:
LiquidCrystal lcd(?, 11, 5, 4, 3, 2);      // put your pin numbers here

... as you didn't tell us how you connected the RS line I have left that value above as a "?".  So this will not compile until you fill in the missing information.
It should be added, based on what can be seen in the picture, that a connection has been made to the LCD's RS & RW pins and no connection has been made to the LCD's E (enable) pin.  But in all the constructor's overloaded versions, there is always an E (enable) pin.  Please take a closer look at your design to determine if this is a problem.

In my case the issue was trivial: the LCD pins were not making good contact with the breadboard.
By firmly inserting them and reuploading you should be able to see "hello world!"


text:
Dimming this ~30V led with PWM, what do I need?
I have a street lamp with a led and simple driver in it, I don't know the exact led voltage but the driver (image attached) says 27-36V DC output, MODEL: 50W.
Is there a part I could place between this driver and the led, so I can control dimming by Arduino via PWM ?
The led driver specs (large image below) says: INPUT; AC 85-285V and OUTPUT: DC 27-36V 1500mA, MODEL: 50W
I thought it would work to put this "PWM power module" between the driver output and the led, but (I tested months ago) I remember it started to blink, I think only when decreasing power but not on full power (controlled by PWM with arduino).

Should it work with this module or I am trying something very wrong ?
Are there any other parts that should work for sure in this situation ?

The specs on the PWM module are these:
Voltage: 5 V - 36 V DC;
Power: 400 W;
Current: 30 A;
PWM Voltage: 3.3-20V;
PWM frequency: 0-20kHz ;

your question is unrelated to the arduino ... why are you asking here?

because I need it to work with Arduino, otherwise I can find parts that control dimming with a rotating knob, but this is an Arduino project.

your question is about the LED power supply, not anything that controls it ...  you would have the same question if you used a 555 timer for dimming ... technically, you are actually asking if you can use a rotating knob to dim the LEDs ... and it has been answered that no, you cannot

No, that is not what I asked, it is an Arduino project, I used arduino board, software and modules to connect to this driver. I needed to know where the problem is.

it makes no difference how you generate a PWM control signal, software or hardware, the result is the same ... that makes arduino irrelevant to the question ... if you cannot control the power supply with a 555 timer, then you cannot control it with an arduino either

It will not be possible for you to PWM dim your LED with that LED driver (power supply).
That is a constant current driver with under/over-voltage protection. It delivers a specific amount of current (1.5A) and varies the voltage to allow that to happen.
If the voltage rises too high or falls too low then there must be a fault, so it shuts the power off. This is usually because there is either a short (LEDs tend to "fail short") or an open circuit. The former causes the voltage to drop too low and the latter for it to be too high.
When you insert PWM control you alternate between driving the LEDs and an open circuit. If that open circuit persists too long (low duty cycles) the driver will shut off.
You will need to replace the LED driver (the power supply) with one which includes PWM control internally to it.

Can you give me more info on what kind of power supply I should look for ? I tried looking for pwm led driver 220v module but closest I could find was controllers with knob for PWM control.

No, I can't. I don't know what is available. All I know is that you can't PWM the output of that power supply and you need to find one that you can.

If you buy a 30V current-limiting power supply set to limit the current to 1.5A, you should be able to use it to power your LED light through a high power logic level MOSFET. You could control the MOSFET with a PWM signal from an Arduino and use that to vary the brightness of your light. With a little googling I found an adjustable power supply with an output ranging from 0-30V and a power rating of 0 - 1.5A https://www.canakit.com/r182-0-30v-0-1.5a-adjustable-regulated-power-supply.html
It does not look to be weather-proofed like the one you show however, and you'd need to make sure the heat-sink was able to dump enough heat to prevent it from overheating.


text:
Set acceleration for stepper motor with no ending
I have a problem. I am using a stepper motor with 2 buttons. In my code I am trying to rotate the stepper motor clockwise while holding button1 and counter-clockwise while holding button2. To do that, I had the following code:
#include <AccelStepper.h>

// Define button pins
#define btnLowerPin 5
#define btnRaisePin 6

// Define stepper motor connections and motor interface type.
#define dirPin 2
#define stepPin 3

int btnLowerState = 0;
int btnRaiseState = 0;

// Create a new instance of the AccelStepper class:
AccelStepper stepper = AccelStepper(AccelStepper::DRIVER, stepPin, dirPin);

void setup() {
  // initialize the button pins as an input:
  pinMode(btnLowerPin, INPUT);
  pinMode(btnRaisePin, INPUT);

  // Set the maximum speed in steps per second:
  stepper.setMaxSpeed(1000);
}
void loop() {
  // read the state of the button values:
  btnLowerState = digitalRead(btnLowerPin);
  btnRaiseState = digitalRead(btnRaisePin);

  if (btnLowerState == LOW) {
    stepper.setSpeed(-1000);
    stepper.runSpeed();
  }
  else if (btnRaiseState == LOW) {
    stepper.setSpeed(1000);
    stepper.runSpeed();
  }
  else {
    stepper.setSpeed(0);
    stepper.runSpeed();
  }
}

This code worked, but I have to accelerate the motor to the speed of 1000. I found this article that explains how to do that: https://www.makerguides.com/28byj-48-stepper-motor-arduino-tutorial/. In code #3 they use the following code:
void setup() {
  // Set the maximum steps per second:
  stepper.setMaxSpeed(1000);
  // Set the maximum acceleration in steps per second^2:
  stepper.setAcceleration(200);
}
void loop() {
  stepper.moveTo(8192);
  stepper.runToPosition();

  delay(1000);

  stepper.moveTo(0);
  stepper.runToPosition();

  delay(1000);
}

Now I tried combining it, but the problem is that I don't know how far the motor has to rotate, because its While holding the button. Here was my code:
void loop() {
  // read the state of the button values:
  btnLowerState = digitalRead(btnLowerPin);
  btnRaiseState = digitalRead(btnRaisePin);

  if (btnLowerState == LOW) {
    stepper.moveTo(8000);
    stepper.runToPosition();
  }
  else if (btnRaiseState == LOW) {
    stepper.moveTo(0);
    stepper.runToPosition();
  }
  else {
    stepper.setSpeed(0);
    stepper.runSpeed();
  }
}

But this code stops when the loop is over and restarts the acceleration. How can I fix this?
So in short:

The motor needs to accelerate when you start holding the button.
The acceleration has to be 300 and max speed 1000.
When you release the button it decelerates to 0.

I think you should be able to use move() instead of moveTo()


text:
How to override automatic control in Blynk app?
I am a beginner to Blynk, and have successfully built a simple water temperature control project. It consists of an ESP32, a plug-in water heater, and an AC relay board. The ESP32 controls the relay board, while the water heater is plugged into the relay board.
The code I have will turn on the relay once the water temperature dips below 16°C. On the Blynk app, I want to add a button that allows the user to manually control the operation of the relay. But I am stumped as to how to code it. Since I have programmed the ESP to turn off the relay once the temperature is above 16°C, if I try to switch it on manually at 20°C, for example, the relay will not remain on, because the if statement will fail.
How can I code this to have a manual override capability, so that once the user turns on the button inside the Blynk app, the ESP will allow manual control of the digital pin (delay trigger), and will only revert back to automatic temperature control mode once the button is turned off?
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 14        //data wire connected to pin 14
#define RELAY_PIN 23           //IoT relay connected to pin 23

OneWire oneWire(ONE_WIRE_BUS); //instance to communicate with any OneWire device

DallasTemperature sensor(&oneWire); //pass reference to Dallas Temperature object

BlynkTimer timer;       //create Blynk timer object for timed intervals
float waterTemp;        //temperature from DS18B20 in C

char auth[] = "xxxxxxx";
char ssid[] = "xxxxxxx";
char pass[] = "xxxxxxx";

void setup() {
  Serial.begin(9600);
  sensor.begin();
  Blynk.begin(auth, ssid, pass);
  sensor.setResolution(9);           //default is 9 bit
  timer.setInterval(1000L, sendTemp);
  pinMode(RELAY_PIN, OUTPUT);
  digitalWrite(RELAY_PIN, LOW);
}

void sendTemp() {
  sensor.requestTemperatures();      //must request reading first
  waterTemp = sensor.getTempCByIndex(0);
  if (waterTemp != DEVICE_DISCONNECTED_C) {
    Serial.print("Temp = ");
    Serial.println(waterTemp);
    Blynk.virtualWrite(V1, waterTemp);
    if (waterTemp < 16) {
      digitalWrite(RELAY_PIN, HIGH); //turn on IoT relay
    } else {
      digitalWrite(RELAY_PIN, LOW);  //turn off IoT relay
    }
  } else {
    Serial.println("Error: Could not read temperature data");
    Blynk.notify("Error: Could not read temperature data");
    digitalWrite(RELAY_PIN, LOW);
  }
}

void loop(void) {
  Blynk.run();
  timer.run();
}

use a state variable

if(is_manual){ do new stuff}else{ run old code} Also, this sounds like a fire hazard. I would have another thing make sure to kill everything if it gets too hot, not just the esp either, those can lockup. A thermal fuse would be good.

Roughly like this:
Make a global variable int mode;
Read a Blynk app 3-way switch in the loop();
Set mode to the 1, 2, or 3 received from the Blynk app (for ON/OFF/AUTO);
Replace this bit of code:
if (waterTemp < 16) {
  digitalWrite(RELAY_PIN, HIGH); //turn on IoT relay
} else {
  digitalWrite(RELAY_PIN, LOW);  //turn off IoT relay
}

with
if (mode == 1) {
  digitalWrite(RELAY_PIN, HIGH);
} else if (mode = 2) {
  digitalWrite(RELAY_PIN, LOW);
} else {
  if (waterTemp < 16) {
    digitalWrite(RELAY_PIN, HIGH); //turn on IoT relay
  } else {
    digitalWrite(RELAY_PIN, LOW);  //turn off IoT relay
  }
}

You will still have to decide what happens when DEVICE_DISCONNECTED_C == TRUE, etc, but that is the gist of it.


text:
Form a signal from an array of bits
I need to reproduce with a digital pin of an Arduino such a key in the form of a sequence of 1's and 0's, where a one takes 2 ms high and 2 ms low, and a zero takes 1 ms high and 1 ms low.

  int key = 0b101100001111;

void setup()
{
  pinMode(13, OUTPUT);
}

void loop()
{
  for (int n = 0; n < 12; n++)
  {
    if (bitRead(key, n) == 1) //execute if bit value == 1
    {
      sendSignal(2000);
    }

    else //execute if bit value == 0
    {
      sendSignal(1000);
    }
  }
}

void sendSignal(int duration)
{
  digitalWrite(13, HIGH);
  delayMicroseconds(duration);
  digitalWrite(13, LOW);
  delayMicroseconds(duration);
}

This sketch really works! I figured out what my problem is: I actually need a longer key (64 bits). I am using long type: long key = 0b1000011110001101111100011111001010110001101101111011011100110100; but long only allows 32 bits. What do you recommend to do? Maybe you need to arrange it as an array? I think you can make it easier somehow. thank you

you did not ask a question

0b101100001111 can never fit into a byte.

That new version of the code you posted works for me, no warnings. Which Arduino are you compiling for?

Arduino Uno. Did you manage to blink the LED?

Not visually, because the delayMicroseconds() is too short for the human eye. My oscilloscope shows the right signal. If you want to check visually, replace delayMicroseconds() with delay().

Thanks you! This sketch really works!
I realized what my problem is: in fact, I need a longer key (64 bits). I am using long type:
long key = 0b1000011110001101111100011111001010110001101101111011011100110100;
But long only allows 32 bits. What do you recommend to do? Maybe you need to arrange it as an array? I think you can make it somehow easier. Thank you

There's always an uint64_t to try, on many machines aka long long int.

You should make
byte key = 0b101100001111;

global, i.e. put it BEFORE the setup function and not within it.
Also, a byte only can contain 8 bits, you need 12, so make it an int (thanks to ocrdu, see comment below):
int key = 0b101100001111;

If you need more bits, you can use uint32_t or uint64_t, and count further than the current 12.
Now key is a local variable which is removed after exiting the setup function.
I'm not sure where 'key' comes from in:
switch (bitRead(key, n)) {

Do you get a compiler error, or did you ALSO define a global variable named key ?
Anyway, if you make key global it will fix either way.
A few other remarks:

Try to align your parenthesis, like the 3 }'s at the end, indent them properly, this makes your code much more readable
Instead of the switch/case, you could use an if statement in this case, as the re are only (and always) two possible values (0 and 1):

Thus:
 if(bitRead(key, n) == 0)
 {
     ...
 }
 else // 1
 {
     ...
 }

Try also comments to write in English instead of Greek, you never know when your comments will be read by non Greek readers (like now).

You can make the following fragment shorter and less duplicated:

Original:
digitalWrite(13, HIGH);
delayMicroseconds(1000);
digitalWrite(13, LOW);
delayMicroseconds(1000);

If you wrap this in a function:
void sendSignal(int duration)
{
    digitalWrite(13, HIGH);
    delayMicroseconds(duration);
    digitalWrite(13, LOW);
    delayMicroseconds(duration);
}

Then you can write a 1 by calling:
sendSignal(2000);

and a 0 by calling:
sendSignal(1000);

It's Russian, not Greek. Just saying 8-).

@orcdu thanks :-)

Thank you very much! Really good advice! Did this, it seems like the sketch is without errors and it is loaded into the board. But I cannot track these impulses on an oscilloscope. I tried to change the duration of the impulses by a few seconds, but I don't see the banal blinking of the LED on the 13th pin with my eye, it is always on.
I don't understand what's wrong, everything seems to be logical in the sketch

int key, not byte key. 12 bits won't fit.

@ocrdu good point, I will update my answer

@Антон See the comment of ocrdu; that is an additional bug fix.

You might consider next time remove the Arduino specific lines and use a PC debugger to step through it.

@Downvoter, can you instead of downvoting all my posts, explain WHY you downvoted, so I may improve the post.

If you modify the code slightly, you can use an array of characters of any length, so need to worry about digital word length.
Here's a modified version of your program that does this.
Note that I also took the liberty of replacing the 'magic number' 13 with LED_PIN, and the 'magic number' 12 with KEY_LEN.  I would suggest you do the same with your pulsewidth values - maybe something like PULSE_WIDTH_ONE_USEC and PULSE_WIDTH_ZERO_USEC?  That way someone else (or you 3 months later) looking at your code can easily see what the values are intended to do
const int KEY_LEN = 62;
const char key[KEY_LEN] = { "10110110110101111001011010110100101011011100110110101101101100" };
const int LED_PIN = 13;

//int key = 0b101100001111;
void setup()
{
  Serial.begin(115200);
  pinMode(13, OUTPUT);
}

void loop()
{
  for (int n = 0; n < KEY_LEN; n++)
  {
    if (key[n]== '1') //execute if bit value == 1
    {
      Serial.print("1");
      sendSignal(200);
    }

    else if (key[n] == '0')//execute if bit value == 0
    {
      Serial.print("0");
      sendSignal(100);
    }
    else
    {
      Serial.print("x");
    }
  }
  Serial.println();
}

void sendSignal(int duration)
{
  digitalWrite(LED_PIN, HIGH);
  //delayMicroseconds(duration);
  delay(duration);
  digitalWrite(LED_PIN, LOW);
  //delayMicroseconds(duration);
  delay(duration);
}


text:
Looking for information and/or how to connect the RF433Mhz module (WL101-341/WL102-341)
I'm trying to find information about this 433MHz RF module: QIACHIP

Apparently it can be connected to an Arduino with the RadioHead library, but I don't have diagrams of how to connect them togheter in order to send/recieve data, becasue the module have 4 pins (Vcc, Gnd, Dat and En). I guess Dat pin should be connected to any Arduino pin, but as I only have one module I dont wanna risk it. I have no previous experience with RF modules :-(
I have found some Youtbe video, but the language of the video is in russian, and I don't know that langauge (I even ask the owner of the chanel for subtitles).
Please, if anyone have worker whit this module before, share:

How to connect the module with an arduino?
A simple example of how to send a simple word (let's say: "Hello") from the transmitter to the reciever

You're right not to just go ahead and wire things up. There's a couple of nuances that you need to take into account.
Transmitter

Ignore the EN pin - that does nothing on that module
The transmitter is 1 3.3V device. You need to power it from the 3.3V pin and use logic level (5V -> 3.3V) translation on the Data pin

simulate this circuit – Schematic created using CircuitLab
Receiver
The receiver is much simpler as it is a 5V device:

simulate this circuit
On the Arduino it shouldn't matter what IO pin you use, the Radiohead library should work fine with any of them.  These modules are pretty dumb - you raise DAT high on the TX and DO on the RX goes HIGH. Very simple.

Thanks! If you would't tell me about the Tx is a 3.3V device I surely would fried it! I think I have a shift converter laying around or could use the VoltageDivider as well. Thanks! I will try now

Hi @Majenko, I already connect everything as you draw it: Tx on a Nano 3V3 and DAT pin to HIGH (trough a VoltageDivider), Rx on an UNO, but when I read the D0 with the UNO I get only 0. Can you share how to make these Tx and Rx modules comunicate among them? Im trying to get some info, but the RadioHead library doesn't seem to be writen for these modules... It should work tho, cuz the russian guy for the Youtube vid I shared make them work...

Well, I make it work: I remove the VoltajeDivider and hook up the PIN12 in the NANO directly to the DAT pin on the Tx, using RadioHead library, and Im now able to send data from the Tx to the Rx...


text:
Arduino "Maximum Power point tracker" (MPPT) Problem
I need an IV curve for a solar panel. As far I know, solar-panel and Diode IV curve pretty much the same. Here, I am using diodes(6A10-1) as a solar-panel. Where each Diode voltage drops 0.6volt. I provide 4.8v across the diodes from a power supply and limited the current at 1amp of the power supply for acting like a solar panel.
The number of diodes is 8 for a 4.8V drop. A 1-ohm resistor for measuring the current. I am using Arduino to measure the value of current and voltage by varies the MOSFET(IRF540) gate voltage. A low pass filter is connected between D2 and Mosfet Gate. A0 for measuring the solar voltage and Current, Id=A0-A1.
But Arduino gives incorrect values of A1 and current, Id, and sometimes negative values with respect to a multimeter.
[
const int V1 = A0;
const int V2 = A1;
float SolarVolt = 0.0;
float V1_VOLT = 0.0;
float V2_VOLT = 0.0;
float Id  = 0.0;
int V1_value = 0;
int V2_value = 0;
double gateVoltage=150; //For Gate volt
double mstep=5.1;
int GatePin=2;

void setup() {
  pinMode(GatePin,OUTPUT);
  Serial.begin(9600);
  pinMode(V1,INPUT);
  pinMode(V2,INPUT);
}

void loop() {
  analogWrite(GatePin,gateVoltage);
  gateVoltage=gateVoltage+mstep;
  Serial.print("GateVolt = ");
  Serial.print(gateVoltage);
  Serial.print("    ");
  if (gateVoltage <= 0) {
    mstep = 1;
  } else if (gateVoltage>=255){
    gateVoltage = 255;
    mstep = -1;
    delay(50);
  }

  V1_value = analogRead(V1);
  V1_VOLT = (V1_value * 5.0) / 1024.0;

  Serial.print("V1_VOLT= ");
  Serial.print(V1_VOLT);
  Serial.print("    ");

  V2_value = analogRead(V2); // for Id1
  V2_VOLT= (V2_value * 5.0) / 1024.0;

  Serial.print("V2_VOLT= ");
  Serial.print(V2_VOLT);
  Serial.print("    ");

  Id=V1_VOLT-V2_VOLT;

  Serial.print("ID= ");
  Serial.print(Id);
  Serial.println();

  delay(1000);
}

The garbage values like -0.5V,-0.02,-1.2V,+4V. I measured with a multimeter and the multimeter shows the correct values. PWM signal passed through a low pass filter, which gives a triangular DC voltage to the gate. No, I did not use any external DAC.

What values are you seeing? Have you measured the voltages with a multimeter? You do realise you are trying to send a PWM signal to the FET's gate, or do you somehow have a DAC on pin 2?

What raw Vx_value-s are you getting from the analogRead(Vx)? BTW Id = (V1-V2)/R.

Here R is one ohm. That's why  Id = (V1-V2). Vx values are some times positive some times negative. But I didn't get the correct values with respect to multimeter.

Are you getting negative values for V1_value and V2_value?

Your current signal will also show PWM, so you will need to filter that before measuring.  It would be much simpler if you could rearrange your circuit to put the sense resistor on the ground side of the MOSFET, since then you can use a simple RC filter and a single A0 measurement.   Also, you wouldn't have to worry about the no-load voltage from the solar panel (when the MOSFET is off) going above the 5V limit of the A0 pin.

A low pass filter is connected between D2 and Mosfet Gate. Yes, I also told my faculty to put the sense resistor on the ground side of the MOSFET. But he told me to not connect it there. But  I forget the reason. Thank you.


text:
How to increase the frequency of data transmission of SIM900A GSM Module connected to Arduino Uno?
I have a SIM900A GSM Module hooked onto an Arduino Uno board. The Arduino is connected to a MPU6050 Accelerometer which is constantly monitoring data at 1 second interval. I am trying to transmit the gathered data to ThingSpeak server. I have successfully established the connection with the server and the transmission is occurring. However, the interval between two transmitted readings are very large, varying between 1 to 3 minutes. That interval is too large to use the data. Is there any way I can enhance the transmission frequency so that the data points are close enough? At least to a few seconds distance?

Just to verify, could you check if once per 20s works better? A free account will reject updates more frequent than once every 15s (showing HTTP 200 with a "0" response).

My thingspeak account is operated through my university granted mathworks account. It is a licensed account. The problem I am encountering concerns the transmission part. The module processes a whole bunch of AT commands then only gathers the data and send to server.

Start simple and add features as the simple things work.  Also, with out your code we can suggest little.  That said, create a version of code to send fixed data to the server and verify you can post data as often as you would like.  Many servers will throttle your updates if you post to fast.  Then add the accelerometer.  Get that working.  Then add the GPS.

Why not buffer 15 mins worth of samples and send them all at once?

@dandavis Your solution has crossed my mind and I did give that a go. But I could not make that work, mostly because of my lack of expertise. Can you point me towards the right direction?

There does not appear to be a complete description of how ThingSpeak throttling works.  However there is this text on the Thing Speak License FAQ web page:

As a reference, one unit provides the ability for a device sending
data to ThingSpeak at once per second to send data to ThingSpeak for
one year.

Assuming your code is working as expected and the ThingSpeak throttling is to suspend your service for 15 minutes, it may be that you are sending data faster than ThingSpeak will allow.
To test this, try to send messages slower than once per second.


text:
Problem with L293D controlled motors using IR pilot remote
I have a problem with my line follower:
My robot has 4 wheels with DC motors connected to L293D shield (Arduino Uno).
The robot is a line follower controlled by IR pilot with an IR receiver, it has 4 IR sensors(two in the back and two in the front). The robot goes forward if none of sensors sees the black line.
When I click > button, the robot should use only the sensors in the front and follow the line until the end of the road made of black tape, and when I click < it should use only the sensors on the back and run CarBackward() (go backwards).
The robot should only stop working if I click 0 button on the pilot (CarStop() function). So without the IR remote code the robot drives normally, but when I add the code for the pilot only two right motors work, they spin forward and nothing else happens no matter if one, two or none sensors see the line.
Everything is powered by two 18650 batteries.
The IR pilot receiver is connected to A0 pin on the shield - pin 14 (which can be used as digital).
#include <IRremote.h>
#include <AFMotor.h>

int IRsensorPin = 14;
AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);

IRrecv irrecv(IRsensorPin);
unsigned long key_value = 0;
decode_results results;

const int back_left_sensor_pin = A0;
const int left_sensor_pin = A1;
const int back_right_sensor_pin = A2;
const int right_sensor_pin = A3;
int left_sensor_state;
int back_left_sensor_state;
int right_sensor_state;
int back_right_sensor_state;

void CarBackward()
{
  if (back_left_sensor_state > 500 && back_right_sensor_state < 500)
  {
    Serial.println("turn right");
    motor1.run(BACKWARD); // LP
    motor2.run(RELEASE); // LT
    motor3.run(BACKWARD); // PT
    motor4.run(FORWARD); // PP

    motor1.setSpeed(160);
    motor2.setSpeed(130);
    motor4.setSpeed(180);
    delay(20);
  }

  if (back_left_sensor_state < 500 && back_right_sensor_state > 500)
  {
    Serial.println("turn left");
    motor1.run(FORWARD); // LP
    motor2.run(BACKWARD); // LT
    motor3.run(RELEASE); // PT
    motor4.run(BACKWARD); // PP

    motor1.setSpeed(180);
    motor4.setSpeed(160);
    motor3.setSpeed(130);
    delay(20);
  }

  if (back_left_sensor_state < 500 && back_right_sensor_state < 500)
  {
    Serial.println("forward");
    motor1.run(BACKWARD); // LP
    motor2.run(BACKWARD); // LT
    motor3.run(BACKWARD); // PT
    motor4.run(BACKWARD); // PP

    motor1.setSpeed(110);
    motor2.setSpeed(110);
    motor3.setSpeed(110);
    motor4.setSpeed(110);
    delay(20);
  }

  if (back_left_sensor_state > 500 && back_right_sensor_state > 500)
  {
    Serial.println("stop");
    motor1.setSpeed(0);
    motor2.setSpeed(0);
    motor3.setSpeed(0);
    motor4.setSpeed(0);
    delay(20);
  }
}

void CarForward()
{
  if (right_sensor_state > 500 && left_sensor_state < 500)
  {
    Serial.println("turn right");
    motor1.run(FORWARD); // LP
    motor2.run(FORWARD); // LT
    motor3.run(RELEASE); // PT
    motor4.run(BACKWARD); // PP

    motor1.setSpeed(160);
    motor2.setSpeed(130);
    motor4.setSpeed(180);
    delay(20);
  }

  if (right_sensor_state < 500 && left_sensor_state > 500)
  {
    Serial.println("turn left");
    motor1.run(BACKWARD); // LP
    motor2.run(RELEASE); // LT
    motor3.run(FORWARD); // PT
    motor4.run(FORWARD); // PP

    motor1.setSpeed(180);
    motor4.setSpeed(160);
    motor3.setSpeed(130);
    delay(20);
  }

  if (right_sensor_state < 500 && left_sensor_state < 500)
  {
    Serial.println("forward");
    motor1.run(FORWARD); // LP
    motor2.run(FORWARD); // LT
    motor3.run(FORWARD); // PT
    motor4.run(FORWARD); // PP

    motor1.setSpeed(110);
    motor2.setSpeed(110);
    motor3.setSpeed(110);
    motor4.setSpeed(110);
    delay(20);
  }

  if (right_sensor_state > 500 && left_sensor_state > 500)
  {
    Serial.println("stop");
    motor1.setSpeed(0);
    motor2.setSpeed(0);
    motor3.setSpeed(0);
    motor4.setSpeed(0);
    delay(20);
  }
}

void CarStop()
{
  Serial.println("stop");
  motor1.run(RELEASE);
  motor2.run(RELEASE);
  motor3.run(RELEASE);
  motor4.run(RELEASE);
  delay(200);
}

void setup()
{
  // put your setup code here, to run once:
  Serial.begin(9600);
  irrecv.enableIRIn();
  irrecv.blink13(true);
  motor1.setSpeed(130);
  motor2.setSpeed(130);
  motor3.setSpeed(130);
  motor4.setSpeed(130);
}

void loop()
{
  left_sensor_state = analogRead(left_sensor_pin);
  right_sensor_state = analogRead(right_sensor_pin);
  back_left_sensor_state = analogRead(back_left_sensor_pin);
  back_right_sensor_state = analogRead(back_right_sensor_pin);

  static int wariat_na_lini = 1;  // if = 1 follow the line and go forward, if -1 go backwards

  if (irrecv.decode(&results)) // have we received an IR signal?
  {
    if (results.value == 0xFFFFFFFF) // if the value is equal to 0xFFFFFFFF
    {
      results.value = key_value; // set the value to the key value
    }
    switch (results.value)
    {
      case 0xCBA816E1:
      case 0xC078:
        Serial.println("right button");
        wariat_na_lini = 1;
        break;
      case 0x43D69629:
      case 0xC0F8:
        Serial.println("left button");
        wariat_na_lini = -1;
        break;
      case 0xA6F5461D:
      case 0xC004:
        Serial.println("stop button");
        wariat_na_lini = 0;
        CarStop();
        break;
      default:
        Serial.println("different code");
        break;
    }
    key_value = results.value; // store the value as key_value
    irrecv.resume(); // reset the receiver for the next code
  }

  if (wariat_na_lini > 0) CarForward();
  else if (wariat_na_lini < 0) CarBackward();
}

So my question is - why are there only right motors working when the ir receiver is plugged?
This is my motor driver:

You may want to edit your question to add in a link for your exact shield.

edited, i thought that it was obvious that i want to know why doesnt it work with the sensor in? i've added an image of this l293d motor driver

@WojtekHawryluk, it is possible that it wasn't needed.  Then again, it may be that it factored into the answer you just received.

Your problem is most likely this line:
  irrecv.blink13(true);

That is intended to flash an LED on pin 13 when you use your IR remote. However pin 13 is also used by the motor shield as part of the serial protocol to communicate with the control chips.
By using that you are confusing the motor shield.
Just remove that line should allow the motors to work again.

didn't help, deleted this and still only right motor worked for a while, then turned off after a few seconds and i had to turn it off and on again.


text:
How to test continuity on signal wire?
I’m reassembling an LED strip, SK6812, that I had cut into smaller lengths. I don’t have a lot of faith in the connectors I’m using or my ability to solder, so I’d like to test it before I put power to it. A simple continuity test is easy for the power “wires” but how do I test the signal “wire”?

The easiest way to test that is to use it, first checking that data doesn't have continuity with gnd or v+ (although that shouldn't really hurt anything anyway).

If you have a multimeter, that has a continuity or resistance measurement mode, you can use this. And when you suspect the connectors being bad, you could just measure the continuity on the wires at both sides of the connector. That is the same for power and data lines


text:
Why doesn't LCD 16x2 work with fingerprint sensor code?
When I separate fingerprint code and LCD code it works fine. sensor read 6 templates which I already stored 6 fingers ID. When I combine the code it read 0 templates.
#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>
#include<LiquidCrystal.h>

int Contrast=100;
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);

// pin #7 is IN from sensor (GREEN wire)
// pin #6 is OUT from arduino  (WHITE wire)
SoftwareSerial mySerial(6,7);

uint8_t id;
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

#define S1 14 //Button candidate A
#define S2 15 // Button candidate B
#define S3 16 // Button candidate c
#define S4 17 // Button candidate D
#define S5 18 // Button Result
#define S6 2 // Button Add unregistered voter
#define S7 4 // Button to cast vote
int can1=0;
int can2=0;
int can3=0;
int can4=0;

void setup()
{
  pinMode(S1, INPUT);
  pinMode(S2,INPUT);
  pinMode(S3,INPUT);
  pinMode(S4,INPUT);
  pinMode(S5,INPUT);
  pinMode(S6,INPUT);
  pinMode(S7,INPUT);

  digitalWrite(S1, HIGH);
  digitalWrite(S2, HIGH);
  digitalWrite(S3, HIGH);
  digitalWrite(S4, HIGH);
  digitalWrite(S5, HIGH);
  digitalWrite(S6, HIGH);
  digitalWrite(S7, HIGH);

  analogWrite(6,Contrast);
  lcd.begin(16, 2);
  lcd.print("  Polling Day  ");
  lcd.setCursor(0,1);
  lcd.print("      UPM      ");
  delay(4000);

  Serial.begin(57600);
    lcd.clear();
    lcd.print("Finding Module");
    lcd.setCursor(0,1);
    delay(1000);
    if (finger.verifyPassword())
    {
      //Serial.println("Found fingerprint sensor!");
      lcd.clear();
      lcd.print("Found Module ");
      delay(1000);
    }
    else
    {
    //Serial.println("Did not find fingerprint sensor :(");
    lcd.clear();
    lcd.print("module not Found");
    lcd.setCursor(0,1);
    lcd.print("Check Connections");
    while (1);
    }

    finger.getTemplateCount();
    lcd.clear();
    lcd.print("contains");
    lcd.setCursor(0,1);
    lcd.print(finger.templateCount);
    delay (4000);
}

uint8_t readnumber(void) {
  uint8_t num = 0;

  while (num == 0) {
    while (! Serial.available());
    num = Serial.parseInt();
  }
  return num;
}

void loop(){
  lcd.clear();
  lcd.setCursor(1,0);
  lcd.print("Place Your");
  lcd.setCursor(0,1);
  lcd.print("Finger");
  delay(4000);
  getFingerprintIDez();
  delay(50);

    if(digitalRead(S5)==0) // To view the result for admin only
    {
      int total=can1+can2+can3+can4;
    if(total)
    {
      if((can1 > can2 && can1 > can3 && can1 > can4))
    {
      lcd.clear();
      lcd.print("Can A is Winner");
      delay(3000);
      lcd.clear();
    }
    else if((can2 > can1 && can2 > can3 && can2 > can4))
    {
      lcd.clear();
      lcd.print("Can B is Winner");
      delay(3000);
      lcd.clear();
    }
    else if((can3 > can1 && can3 > can2 && can3 > can4))
    {
      lcd.clear();
      lcd.print("Can C is Winner");
      delay(3000);
      lcd.clear();
    }
    else if(can4 > can1 && can4 > can2 && can4 > can3)
    {
        lcd.setCursor(0,0);
        lcd.clear();
        lcd.print("Can D is Winner");
        delay(3000);
        lcd.clear();
    }

    else if(can4 > can1 && can4 > can2 && can4 > can3)
    {
        lcd.setCursor(0,0);
        lcd.clear();
        lcd.print("Can D is Winner");
        delay(3000);
        lcd.clear();
    }

    else
    {
        lcd.clear();
        lcd.print(" Tie Up Or ");
        lcd.setCursor(0,1);
        lcd.print(" No Result ");
        delay(3000);
        lcd.clear();
    }

    }
    else
    {
        lcd.clear();
        lcd.print("No Voting....");
        delay(3000);
        lcd.clear();
    }
        can1=0;can2=0;can3=0;can4=0,total=0;
        lcd.clear();
    }

    if(digitalRead(S7)==0){ //To cast avote for user
        voterpage();
    }

    if(digitalRead(S6)==0){
      Serial.println("Ready to enroll a fingerprint!");
      Serial.println("Please type in the ID # (from 1 to 127) you want to save this finger as...");
      lcd.clear();
      lcd.print("ENTER ID:");
      delay(2000);
      id = readnumber();
      if (id == 0) {// ID #0 not allowed, try again!
      return;
      }
      Serial.print("Enrolling ID #");
      lcd.print(id);

      while (!  getFingerprintEnroll() );
      }
  }

    void voterpage(){
      lcd.clear();
      lcd.setCursor(1,0);
      lcd.print("A");
      lcd.setCursor(5,0);
      lcd.print("B");
      lcd.setCursor(9,0);
      lcd.print("C");
      lcd.setCursor(13,0);
      lcd.print("D");

      if(digitalRead(S1)==0){
      can1++;
      votereceived();
      }
        while(digitalRead(S1)==0);
      if(digitalRead(S2)==0){
      can2++;
      votereceived();
      }
        while(digitalRead(S2)==0);
      if(digitalRead(S3)==0){
      can3++;
      votereceived();
      }
        while(digitalRead(S3)==0);
      if(digitalRead(S4)==0){
      can4++;
      votereceived();
      }
        while(digitalRead(S4)==0);
}

void votereceived(){
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("Vote Received");
      lcd.setCursor(2,1);
      lcd.print("Thank You :)");
      delay(2000);
}

uint8_t getFingerprintEnroll() {

  int p = -1;
  Serial.print("Waiting for valid finger to enroll as #"); Serial.println(id);
  while (p != FINGERPRINT_OK) {
    p = finger.getImage();
    switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image taken");
      break;
    case FINGERPRINT_NOFINGER:
      Serial.println(".");
      break;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      break;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("Imaging error");
      break;
    default:
      Serial.println("Unknown error");
      break;
    }
  }

Serial.println("Remove finger");
  delay(2000);
  p = 0;
  while (p != FINGERPRINT_NOFINGER) {
    p = finger.getImage();
  }
  lcd.clear();
  lcd.print("ID ");
  lcd.print(id);
  delay(2000);
  p = -1;
  lcd.clear(); lcd.print("Place same finger again"); delay(2000);
  while (p != FINGERPRINT_OK) {
    p = finger.getImage();
    switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image taken");
      break;
    case FINGERPRINT_NOFINGER:
      Serial.print(".");
      break;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      break;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("Imaging error");
      break;
    default:
      Serial.println("Unknown error");
      break;
    }
  }

  // OK success!

  p = finger.image2Tz();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image converted");
      break;
    case FINGERPRINT_IMAGEMESS:
      Serial.println("Image too messy");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_FEATUREFAIL:
      Serial.println("Could not find fingerprint features");
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      Serial.println("Could not find fingerprint features");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }

  // OK converted!
  p = finger.fingerFastSearch();
  if (p == FINGERPRINT_OK) {
    Serial.println("Found a print match!");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("Communication error");
    return p;
  } else if (p == FINGERPRINT_NOTFOUND) {
    Serial.println("Did not find a match");
    return p;
  } else {
    Serial.println("Unknown error");
    return p;
  }

Serial.print("ID "); Serial.println(id);
  p = finger.storeModel(id);
  if (p == FINGERPRINT_OK) {
    Serial.println("Stored!");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("Communication error");
    return p;
  } else if (p == FINGERPRINT_BADLOCATION) {
    Serial.println("Could not store in that location");
    return p;
  } else if (p == FINGERPRINT_FLASHERR) {
    Serial.println("Error writing to flash");
    return p;
  } else {
    Serial.println("Unknown error");
    return p;
  }
}

uint8_t getFingerprintID() {
  uint8_t p = finger.getImage();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image taken");
      break;
    case FINGERPRINT_NOFINGER:
      Serial.println("No finger detected");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("Imaging error");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }
    // found a match!
  Serial.print("Found ID #"); Serial.print(finger.fingerID);
  Serial.print(" with confidence of "); Serial.println(finger.confidence);
    lcd.clear();
    lcd.setCursor(3,0);
    lcd.print("ID");
    lcd.setCursor(1,1);
    lcd.print(finger.fingerID);
    delay(4000);
    return finger.fingerID;
    if(finger.fingerID==26 ;finger.confidence>100){
      lcd.clear();
      lcd.setCursor(3,0);
      lcd.print("1");
      lcd.setCursor(1,1);
      lcd.print("Result");
      lcd.setCursor(11,0);
      lcd.print("2");
      lcd.setCursor(8,1);
      lcd.print("Register");
      delay(4000);
  }

}

// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez() {
  uint8_t p = finger.getImage();
  if (p != FINGERPRINT_OK)  return -1;

  p = finger.image2Tz();
  if (p != FINGERPRINT_OK)  return -1;

  p = finger.fingerFastSearch();
  if (p != FINGERPRINT_OK)  return -1;

  // found a match!
  Serial.print("Found ID #"); Serial.print(finger.fingerID);
  Serial.print(" with confidence of "); Serial.println(finger.confidence);
  return finger.fingerID;
}

we aren't a code review. strip down the code to the minimal example that still has the problem. often times, you'll find the problem just cleaning it up to post on stack...

@dandavis but I dont know which part of it I got it wrong.

dupe your sketch, start removing code, re-test until there's nothing left to take away (then post that) or the problem goes away (in which case you don't need us anymore).

Can you please share the schematic also and also which fingerprint sensor you are using.

What part "doesn't work"? That is an incredibly vague description. What shows on the LCD display? What appears in the serial monitor?

Also in setup finger.begin(baudrate) is missing add this and I guess it will help you out

@NickGammon Hi I already add the pic of lcd dislpay and serial monitor. Serial reads 6 templates but if I add lcd code it showed 0 templates. Hope you can help thank you :)

@MaazSk hi I dont have the schematic yet but i used JM101 fingerprint. And also I already add the finger.begin(baudrate) still shows the same result on the lcd as I shown in the picture.

@SASHASYAZANA can you try this int m = 0; m = finger.getTemplateCount(); lcd.print(m); this will print the tempelate count for you

@MaazSk I tried using the code. It works! but unfortunately it just contains 1 templates only. supposedly it have 6 templates. And I tried place my fingerprint all of 6 finger not even one works.

Need to check will get back soon


text:
Getting Accurate Velocity Readings From IMU
Hi I am currently using a BNO055 for a design project. This sensor outputs a linear acceleration vector corresponding to three (xyz) directions. I am trying to "integrate" the acceleration to get a speed the object it is mounted to is traveling.
I noticed early on that in my speed graph there is large amounts of drift.
I was looking for any guidance someone might have for tuning out the drift some way or filtering options I could use for acceleration data to reduce the drift

The process of integrating acceleration to derive velocity and integrating velocity to derive position are commonly known as dead reckoning.  In this link it is stated:

Dead reckoning is subject to cumulative errors. Advances in
navigational aids that give accurate information on position, in
particular satellite navigation using the Global Positioning System,
have made simple dead reckoning by humans obsolete for most purposes.

It may help to calibrate each of the 3 accelerometers using Earth's gravity as a constant.  Test if each accelerometer is symmetrical providing the same absolute values when pointed toward the Earth as when pointed away from the Earth. If any are not symmetric calculate an appropriate offset.  Next compare the range of each of the 3 accelerometers.  If they are not the same calculate an appropriate magnitude correction factor for maximum and minimum accelerometer ranges.
To find the offset and range correction values look at page 26 of the BNO055 specification sheet.  There you will find a picture of the BNO055 chip which relates to the direction of the X, Y and Z accelerometers.  Position the chip such that the X accelerometer is pointed downwards toward the earth.  Record the raw value.  Now repeat the measurement with the X accelerometer pointing away from the earth.  The absolute value of these two measurements should be the same.  If not, determine the offset needed to correct X accelerometer measurements and incorporate that value into your program.  Repeat this for the Y and Z vectors.
Now compare the maximum - minimum values for the X, Y and Z accelerometers.  These 3 values should be the same.  If not, find a value to multiply the smallest of the three such that it matches the middle value and incorporate that value into your program. Repeat this for the largest of the three values.
It is desired all 3 accelerometers work the same.  If they do not, using the values derived above should adjust the raw values such as the result appears as 3 nearly identical accelerometers.
That said, most accelerometers are very usable with no correction factors.  And it is expected any correction factors to be small.  However, as experienced, when integrating, small errors can accumulate quickly.
Next consider the application in which dead reckoning is to be used.  There may be clues as to the velocity at a given moment which, if used, can reset the assumed velocity to a known value.  For example, if the accelerometer were attached to a runner's foot, it can be assumed the velocity is zero for each foot to ground impact detected.

How would I find the ranges for the accelerometers?

I added a procedure to the answer.


text:
How do I split an incoming char?
I am sending a list of joystick positions via the serial connection to the arduino in the following format
515;520
Which would be parsed as:
x=515
y=520
How would I split these values up, and convert them to an integer?
MyReceiver:
#include <SoftwareSerial.h>
#define xBeeRxPin 10
#define xBeeTxPin 9
SoftwareSerial xBeeSerial(xBeeRxPin, xBeeTxPin);
char val;

void setup() {
  xBeeSerial.begin(38400);
  Serial.begin(38400);
}
void loop() {

  if(xBeeSerial.available()>0){
   val = xBeeSerial.read();
   Serial.print(val);
  }

}

My Coordinator:
#include <SoftwareSerial.h>
#define xBeeRxPin 10
#define xBeeTxPin 9
int deger1;
int deger2;
SoftwareSerial xBeeSerial(xBeeRxPin, xBeeTxPin);
void setup() {

   xBeeSerial.begin(38400);
}

void loop() {

  deger1 = analogRead(A0);
  deger2 = analogRead(A2);
  char buf[1000];
  const char *first = " ";
  const char *second = ";";
  char val[4];
  char deger[4];

  strcpy(buf,first);
  sprintf(val,"%d",deger1);
  strcat(buf,val);
  strcat(buf,second);
  sprintf(deger,"%d",deger2);
  strcat(buf,deger);

  Serial.print(buf);
  xBeeSerial.write(buf);
  delay(200);
}

Put all characters into a char array. Then use strtok() for splitting and atoi() for converting to integer. Here is the reference for strtok(). You can even open the online editor with the example there (click on "Edit and run") and play with it, until you understand, how it works.

And you can look at my answer to this question. It already explains how to use strtok(). Arduino split comma separated serial stream

I examined but i can not. Can you help me in the code selection above?

Where in the code above are you trying to split a string? I cannot know, where you want to do that. And what do you mean by "I can not"? What exactly is the problem? Have you looked at some tutorials on strtok(). Have you tried yourself in the online editor in the reference, that I linked to? Is my answer to the other question not clear enough? I need to know, where exactly the problem is, so that I'm not just writing down the same stuff as in my other answer, but helping you with the problem.

I cannot directly transfer the data I get from xBee into char buffer[].