text:
Useless box wiring and code
just want to give a back story first. So i saw this video on youtube about the useless box, and i thought that it would make a great gift for my 7 year old. So i went out and bought everything that the guy posted in his description box. Just want to say that i am very new to Arduino and how these things work. I actually just want to build this as a gift to my son. I know on Stack platforms that before you ask questions you need to try yourself, i have been trying to get this thing working for the past 36 hours, and im not getting anywhere.
So here is a list of the things i have tried so far.

Firstly i bought everything exactly the same as what the guy had, imported it so i know its the same stuff.
I downloaded the code and schematic.
I wired the little board 4 times, to make sure i did it correctly.
I have redrawn the schematic in tinkercad to make sure all the wires are going to the correct places.

Here is the link to my tinkercad drawing the code is in there as well. Please note that on tinkercad i cant get the arduino board not to be plugged in by usb, it is supposed to get power from the external power supply (4AA battries).
https://www.tinkercad.com/things/43WIrlmR1K3-project1
Here is a link to the youtube video:
https://www.youtube.com/watch?v=cpdjQ0gheDQ&t=311s
Here is the schematic he provided:

 Here is the Code he provided:
 #include <Servo.h>

Servo handServo;
Servo boxServo;

int switchStatus=0, action=1, vot, randNumber=0;
const int ledPin = 13;
const int frontSwitchPin = 2;
const int handServoPin = 5;
const int boxServoPin = 6;

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

  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin,HIGH);

  handServo.attach(handServoPin);
  boxServo.attach(boxServoPin);
  handServo.write(180);
  boxServo.write(70);

  //randomSeed(analogRead(0));
}

void loop()
{
  switchStatus = digitalRead(frontSwitchPin);
  //action = random(1,16);

  if (switchStatus == LOW){

    if (action == 1)
    {
      Serial.println("Action 1");
      for (int i = 70; i <= 110; i++)
      {
        boxServo.write(i);
        delay(20);
      }
      for (int i = 180; i >= 35; i--)
      {
        handServo.write(i);
        delay(20);
      }
      delay(1000);
      handServo.write(26);
      delay(200);
      for (int i = 26; i <=180; i++)
      {
        handServo.write(i);
        delay(20);
      }
      for (int i = 110; i >= 70; i--)
      {
        boxServo.write(i);
        delay(20);
      }
      action++;
    }

    else if (action == 2)
    {
      Serial.println("Action 2");
      for (int i = 70; i <= 110; i++){
        boxServo.write(i);
        delay(6);
      }
      delay(550);
      handServo.write(26);
      delay(550);
      handServo.write(180);
      delay(550);
      boxServo.write(70);
      delay(1500);
      for (int i = 70; i <= 110; i++){
        boxServo.write(i);
        delay(6);
      }
      delay(3000);
      boxServo.write(70);
      action++;
    }

    else if (action == 3)
    {
      Serial.println("Action 3");
      for (int i = 70; i <= 110; i++){
        boxServo.write(i);
        delay(6);
      }
      delay(1000);
      boxServo.write(70);
      delay(2000);
      for (int i = 70; i <= 110; i++){
        boxServo.write(i);
        delay(6);
      }
      handServo.write(26);
      delay(550);
      handServo.write(180);
      delay(500);
      boxServo.write(70);
      action++;
    }

    else if (action == 4)
    {
      Serial.println("Action 4");
      for (int i = 70; i <= 110; i++)
      {
        boxServo.write(i);
        delay(20);
      }
      for (int i = 180; i >= 35; i--)
      {
        handServo.write(i);
        delay(20);
      }
      delay(2000);
      handServo.write(26);
      delay(200);
      handServo.write(180);
      delay(400);
      boxServo.write(70);
      action++;
    }

    else if (action == 5)
    {
      Serial.println("Action 5");
      for (int i = 70; i <= 110; i++){
        boxServo.write(i);
        delay(6);
      }
      delay(2000);
      handServo.write(65);
      delay(550);
      handServo.write(40);
      delay(200);
      handServo.write(65);
      delay(200);
      handServo.write(40);
      delay(200);
      handServo.write(65);
      delay(200);
      handServo.write(40);
      delay(200);
      handServo.write(65);
      delay(200);
      handServo.write(40);
      delay(200);
      handServo.write(65);
      delay(200);
      handServo.write(40);
      delay(200);
      handServo.write(65);
      delay(2000);
      handServo.write(26);
      delay(400);
      handServo.write(180);
      delay(400);
      boxServo.write(70);
      action++;
    }

    else if (action == 6)
    {
      Serial.println("Action 6");
      for (int i = 70; i <110; i++)
      {
        boxServo.write(i);
        delay(20);
      }
      delay(1000);
      for (int i = 0; i < 12; i++)
      {
        for (int j = 70; j <= 110; j++){
          boxServo.write(j);
          delay(6);
        }
        delay(200);
      }
      for (int i = 180; i >= 35; i--)
      {
        handServo.write(i);
        delay(30);
      }
      handServo.write(26);
      delay(400);
      handServo.write(180);
      delay(400);
      boxServo.write(70);
      delay(1500);
      for (int i = 70; i <= 110; i++){
        boxServo.write(i);
        delay(6);
      }
      delay(3000);
      boxServo.write(80);
      action++;
    }

    else if (action == 7)
    {
      Serial.println("Action 7");
      for (int i = 70; i <= 110; i++){
        boxServo.write(i);
        delay(6);
      }
      delay(400);
      handServo.write(26);
      delay(1000);
      for (int i = 0; i < 6; i++)
      {
        for (int j = 70; j <= 110; j++){
          boxServo.write(j);
          delay(6);
        }
        delay(200);
      }
      delay(500);
      handServo.write(180);
      delay(400);
      boxServo.write(70);
      action++;
    }

    else if (action == 8)
    {
      Serial.println("Action 8");
      for (int i = 70; i <= 110; i++){
        boxServo.write(i);
        delay(6);
      }
      handServo.write(26);
      delay(2000);
      for (int i = 0; i < 7; i++)
      {
        handServo.write(75);
        delay(100);
        handServo.write(40);
        delay(100);
      }
      delay(500);
      handServo.write(180);
      delay(1000);
      boxServo.write(70);
      action++;
    }

    else if (action == 9)
    {
      Serial.println("Action 9");
      for (int i = 70; i <= 105; i++){
        boxServo.write(i);
        delay(6);
      }
      delay(2000);
      boxServo.write(110);
      for (int i = 180; i >=35; i--)
      {
        handServo.write(i);
        delay(40);
      }
      delay(500);
      handServo.write(26);
      delay(200);
      for (int i = 26; i <=180; i++)
      {
        handServo.write(i);
        delay(40);
      }
      boxServo.write(70);
      delay(2000);
      boxServo.write(100);
      delay(3000);
      boxServo.write(70);
      action++;
    }

    else if (action == 10)
    {
      Serial.println("Action 10");
      for (int i = 70; i <= 105; i++)
      {
        boxServo.write(i);
        delay(100);
      }
      delay(1000);
      for (int i = 0; i < 10; i++)
      {
        for (int j = 70; j <= 100; j++){
          boxServo.write(j);
          delay(6);
      }
        delay(100);
      }
      boxServo.write(110);
      delay(100);
      handServo.write(26);
      delay(650);
      handServo.write(180);
      delay(400);
      boxServo.write(70);
      action++;
    }

    else if (action == 11)
    {
      Serial.println("Action 11");
      for (int i = 70; i <= 110; i++){
        boxServo.write(i);
        delay(6);
      }
      handServo.write(26);
      delay(2000);
      for (int i = 0; i < 3; i++)
      {
        handServo.write(65);
        delay(200);
        handServo.write(40);
        delay(200);
      }
      delay(1500);
      handServo.write(180);
      delay(400);
      boxServo.write(70);
      delay(1500);
      for (int i = 70; i <= 110; i++){
        boxServo.write(i);
        delay(6);
      }
      handServo.write(26);
      delay(3000);
      handServo.write(180);
      delay(400);
      boxServo.write(70);
      action++;
    }

    else if (action == 12)
    {
      Serial.println("Action 12");
      for (int i = 70; i <= 110; i++)
      {
        boxServo.write(i);
        delay(50);
      }
      delay(1000);
      for (int i = 180; i >= 26; i--)
      {
        handServo.write(i);
        delay(50);
      }
      delay(2000);
      handServo.write(26);
      delay(200);
      handServo.write(180);
      delay(400);
      boxServo.write(70);
      action++;
    }

    else if (action == 13)
    {
      Serial.println("Action 13");
      for (int i = 70; i <= 110; i++){
        boxServo.write(i);
        delay(6);
      }
      delay(2000);
      for (int i = 180; i >= 60; i--)
      {
        handServo.write(i);
        delay(40);
      }
      for (int i = 0; i < 3; i++)
      {
        handServo.write(60);
        delay(200);
        handServo.write(40);
        delay(800);
      }
      handServo.write(26);
      delay(2000);
      handServo.write(180);
      delay(500);
      boxServo.write(70);
      action++;
    }

    else if (action == 14)
    {
      Serial.println("Action 14");
      for (int i = 70; i <= 105; i++){
        boxServo.write(i);
        delay(6);
      }
      delay(4000);
      boxServo.write(110);
      handServo.write(26);
      delay(650);
      handServo.write(180);
      delay(500);
      boxServo.write(100);
      delay(4000);
      boxServo.write(70);
      action++;
    }

    else if (action == 15)
    {
      Serial.println("Action 15");
      for (int i = 70; i <= 105; i++){
        boxServo.write(i);
        delay(6);
      }
      delay(1000);
      for (int i = 0; i < 3; i++)
      {
        for (int j = 70; j <= 105; j++){
          boxServo.write(j);
          delay(50);
        }
        for (int j = 105; j >= 70; j--)
        {
          boxServo.write(j);
          delay(50);
        }
      }
      for (int j = 70; j <= 110; j++){
        boxServo.write(j);
        delay(50);
      }
      for (int i = 180; i >= 35; i--)
      {
        handServo.write(i);
        delay(40);
      }
      delay(1000);
      handServo.write(26);
      delay(400);
      handServo.write(180);
      delay(400);
      boxServo.write(70);
      action = 1;
    }

  }

}

So in my tinkercad when i run the simulation everything works (exept for the motors breaking but i know it because of the extra power its getting from the usb which i can turn off). When you look in the Serial Monitor it runs through all the "Actions" and when you simulate the button that gets pressed by the servo everthing stops and wait until you toggle the switch again and it goes to the next action.
I have done exactly the same and like i said i wired the board 4 times to make sure its exactly the same. When i switch on the project on my board the servos keep spinning and does not stop and wait for the switch, but when i toggle the switch it actually plays the next "Action", but in the times where it is suppose to wait or stop when the switch is in the off position the servos keep rotating looks like in an anti-clockwise rotation.
Please any help would be greatly appreciated.
If you need more info or if anything is unclear please ask me to provide more and i will. I tried to make it as clear as possible. Thanks

The schematic looks OK to me. Unfortunately I don't have an Arduino at hand, so I can't be more specific. You might like to try another sketch from the examples which demonstrates the usage of a servo. You will adapt that sketch to the servo output you use, and this way you can check whether the servos work at all.

@thebusybee thanks i have tried that the servos worked. I wired the swipe example that arduino gives you and its working 100%. So no issue with the servos. Thanks for the reply

Good to know! Then the next experiment will check the switch. For this you need a sketch which reads the switch and sets the LED on pin 13 to the read value. This should show whether the switch works.

Oh, and when you say "the servos keep rotating" does that mean the servos turn their levers all around 360° in endless circles without stopping?

@thebusybeei i also tested the toggle switch. I deleted all the code and only used the switch, So the i did a if statement to check if it HIGH or LOW and that worked perfectly as well. Yes they turn 360 and when you toggle the switch it does the "Action" that its suppose to do and then go back to turning 360 again until the next Action runs. So basically it does not 'stop' and wait for the switch even if the if statement states only trigger servo if its LOW.

Yes they turn 360

Normal servos turn between 0 and 180° (or a bit more or less). On these servos you can set the angle through Servo.write(). But if the servo spins 360° and more, it is a continuous rotation servo. Here the Servo.write() value sets the rotation speed, not the angle. A value of 90 let's it stand still. Values below 90 means rotation backwards, above 90 forward. The higher the distance from 90, the higher the rotation speed will be.
In the video the servos are mounted in a way, that they cannot spin 360°, so they must be normal servos (that also fits with the code). If your servos spin more, you unfortunately bought the wrong servo type.
The code sets the idle position of the boxservo to 70 and of the handservo to 180. That means, that with a continuous rotation servo both servos would spin in idle state, the handservo being way faster than the boxservo.
So you would need to buy normal servos for this project.

Ah ok i see. I will check out my servos again i know its MG996R Digital Servo towerpro servos. But i see now that you get one that says "DIGI HI TORQUE" and one that say "360 Rotatable". So what you are saying is if its the 360 rotatable servo then it cant work with this project?

this is the exact servo i bought from this place. https://www.communica.co.za/products/bsk-cont-rotat-servo-mg996-11kg

Will that servos work? i see they say its Tower Pro Continuos Rotation Metal Gear Servo Motor 11KG Torque Vin 4.8~ 6.6V 360°

You might get away with this servo by rewriting your code, but honestly I don't think, that you will get happy that way. Directly buying a servo that is not a continuous rotation servo would create a lot less stress for you

thank you so much i will buy other servos and try again.

If you think, that my answer is good, you can accept is as correct. And always be welcome to ask more questions.

Oh boy, the same name for different servos or at least different inner working?! No wonder it didn't work...

Yhea same name just different that's so strange. :( unfortunate. Makes me feel like an idiot hahahaha

Again @chrisl thanks for your help! This is definitely the correct answer


text:
how to wrire into the contents of the registers in ADMV1013 up converter using arduino Due?
There are nine registers inside and the contents of the registers can be changed to perform several operations. The link of the data-sheet is given here(Page 26). The write cycle sampling must be performed on the rising edge.
The 16 bits of the serial write data are shifted in, MSB to lower
sideband.
The link: https://www.analog.com/media/en/technical-documentation/data-sheets/ADMV1013.pdf

I do not understand what you are asking for. Especially "MSB to lower sideband" makes no sense for me. MSB and LSB have nothing to do with the lower or upper side band of the up converter. If you want to program the Due to transfer the data words to the registers of the convert, you could use the SPI library. It is a core library and always available in the IDE. It is documented on the Arduino page. One special note: The converter uses 1.8V input and output level. So you should use a level shifter to connect it to the Due.

https://www.arduino.cc/en/reference/SPI

Yes I am using a level translator to generate 1.8 V for the up converter. I am using the SPI.transfer() command to write into the registers but I could not understand how to change the contents of the registers .I mean when I am sending a specific data by SPI.transfer(data),will that data be stored in the registers???and also if we look into the data sheet of the up converter,you can see the timing diagram for the read and write is mentioned specifically.the changing of the MSB is for to enable  the read or write more if operation.

source: Stack Exchange

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

sort: votes


text:
Uno Wifi rev2 - SSL socket connection
On Arduino Uno Wifi rev2 I want to create an SSL socket to my own SSL socket server implementation.
The board can download a webpage with encryption (after I've installed the certificate into it of course).
For my own SSL socket server implementation I'm using OpenSSL.
The board can connect to my own SSL socket server without any issues.
I want to enable SSL_VERIFY_PEER in my socket server.
With this option I can verify if peer is valid and true.
However after enabling this option, the Arduino is not able to connect to my socket anymore.
My question: is peer certificate sending can be achieved on Ublox NINA W10x?

What is the current code you're using?

I understand the question, but I don't know the answer. the firmware updater allows to upload certificates to nina firmware. the ESP32 IDF used to build the firmware has support for verifying a client certificate.

@MaximilianGerhardt the question is what code do I need to use to ask NINA to provide the client certificate upon request.

@Juraj: Can ESP32 IDF make a firmware for NINA W10x?

you have the firmware in the Uno WiFi Rev 2. only I don't know if the firmware and the library support client certificates

Yes I know that the firmware is in the Uno. (To be more exact it is in the NINA W10x). Do you know ESP32 IDF is able to create a firmware for the NINA W10x?

I don't understand. The arduino nina-fw project uses the IDF framework https://github.com/arduino/nina-fw

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


text:
Initialize ATMEGA32U4 with arduino bootloader with AVR Dragon?
I built my own atmega32u4 board. I wish to use it as "arduino" so I need to upload first the arduino bootloader.
Now, to do that I need another arduino but I don't have it currently.
However I have an AVR Dragon, which was the way to program these chips years back. So: how the heck can I burn the arduino bootloader to the mega32u4 with avr dragon?
Note: I can use AVR Dragon, and it can see the mega. Just I have NO clue on where this ** arduino stores it's bootloader hex file.

You mean like this?

The common simple action to find a file is to use your file manager and ask it to search. You asked your file manager to search "*.hex" in your Arduino installation path, didn't you? Why do the findings not help you?

There is not a single "hex" file in Arduino IDE's folder, hence my question..

Of course not, because there are so many different Arduinos, each one needs its specific bootloader. So you might have to look at the filename. I see "Leonardo-..." as a good hint. ;-) A research on the specific Arduino that uses an ATmega32u4 with the same clock can be expected. -- And if there is still more than one left, then you could ask with the list of candidates. Or visit the project repository to learn more.

You don't need another Arduino if you have a programmer, but there is some problem with the AVR Dargon programmer and avrdude so the Arduino boards package and the MiniCore boards package don't have it configured.
With a supported programmer you can burn the bootloader with Arduino IDE. In Tools menu you select the board most similar to your custom board, then you select in Tools menu the programmer and then you select "Burn bootloader".

See https://github.com/arduino/ArduinoCore-avr/tree/master/bootloaders/caterina
The file you probably want would be Leonardo-prod-firmware-2012-12-10.hex in that folder.
Those files will be in your Arduino installation, in a folder called "bootloaders".

I have an "Arduino IDE" folder in Program Files (Win11). Nothing is related to "bootloader" in that folder. Where am I supposed to find it?

@Daniel IDE 2.x doesn't have it, but he didn't mention anything about ide, neither did I. We both sent url with all bootloaders for 32u4

@Daniel I mentioned the "Arduino installation" - I looked in IDE 1.8.5 on Ubuntu. I can't say where it would be, if anywhere, on your hard disk for Windows 11. However the link I gave is to that folder on Github. You can click on the appropriate link in Github to open the file (it is just text), then RH-click "Raw" and then download it.

Evidently it is a file from 2012, but it doesn't matter. Either the bootloader works or it doesn't, and this one does. ;)


text:
What is ECC608 crypto chip accelerator used for in Arduino Uno Wifi rev2?
Arduino Uno Wifi rev2 includes an ECC608 crypto accelerator chip.
Even their documentation states "As for the WiFi connection, that's made secure with the new ECC608 crypto chip accelerator."
My question is: how exactly the ECC608 is used? I'd like to see the sources the Arduino makes the "WiFi secure" with it.

The library for the chip is ArduinoECCX08. It is used by the ArduinoBearSSL library. The ArduinoBearSSL is used by the ArduinoIoTCloud
 library and Arduino_OAuth library.
.

Thanks. So normally when using WiFiSSLClient (https://www.arduino.cc/en/Tutorial/WiFiNINAWiFiSSLClient), ECC608 is not used at all?

for WiFiNINA, the esp32 firmware handles secure connection with IDF framework utilities.


text:
PC not recognizing Arduino when working with a class and MIDIUSB library
I've recently bought an Arduo Due to create some sort of a Midi controller together with the MIDIUSB library.
I have create a simple a test program with 1 potentiometer (without the use of a class) to test the MIDIUSB library and everything works fine, so I decided to expanded my program to make it work with more than 1 potentiometer (with the use of a class).
However my pc stopped recognizing my Arduino as a MIDI device with my updated code. When I upload my previous example code it all works fine. I get no compile errors or whatsoever.
I don't understand what I'm doing wrong.
If anybody could explain me what I'm doing wrong or could give me a solution you would be a hero since I can't really work further if this issue doesn't get resolved.
Thanks!
Here is my code for Custom_MIDI_controller_V2.ino:
#include "MIDIUSB.h"
#include "Class.h"
#define TOLERANCE 8

byte NUMBER_POTS = 5;

Pot PO0(A0, 1, 14);
Pot PO1(A1, 1, 15);
Pot PO2(A2, 1, 16);
Pot PO3(A3, 1, 17);
Pot PO4(A4, 1, 18);

Pot *POTS[] = {&PO0, &PO1, &PO2, &PO3, &PO4};

void setup() {

}

void loop() {
  for (int i = 0; i < NUMBER_POTS; i++) {
    int potValue = POTS[i]->getValue();
      if(potValue != 255) {
        controlChange(POTS[i]->_channel, POTS[i]->_control, potValue);
        MidiUSB.flush();
      }
   }
}

void controlChange(byte channel, byte control, byte value) {
  midiEventPacket_t event = {0x0B, 0xB0 | channel, control, value};
  MidiUSB.sendMIDI(event);
}

Here is my Class.cpp code:
#include "Arduino.h"
#include "Class.h"

#define TOLERANCE 8

Pot::Pot(int pin, int channel, int control) {
  _pin = pin;
  _channel = channel;
  _control = control;
  _value = analogRead(_pin);
  _oldValue = _value - 10;
}

int Pot::getValue() {
  int diff = abs(_value - _oldValue);
  if(diff > TOLERANCE)
  {
    _oldValue = _value;
    return map(_value, 0, 1023, 127, 0);
  } else {
    return 255;
  }
}

And this is my header Class.h code:
#ifndef Class_h
#define Class_h
#include "Arduino.h"

class Pot
{
  public:
    Pot(int pin, int channel, int control);
    int getValue();
    int _pin;
    int _channel;
    int _control;
    int _value;
    int _oldValue;
};

#endif

Unrelated error: analogRead() is called only once, in the constructor.

Please show the test program that worked.

@CL unrelated? That may well be the root cause - the constructor get called before main() which is where things like analogRead()` may be pre-configured. So it may never get past that point of the program.

What is the point of creating an array of pointers? Just create an array of objects as shown here, for example.

You need to take care with constructors in C++.  They get called during the global variable initialisation phase of the execution, which happens before main() gets called.
main() calls the routines that initialise and configure the peripherals and such in the chip, and by having analogRead() in your constructor (which is itself another error I will mention below) there is a good chance (I don't know the full initialisation sequence of that chip though) that it will never complete, and thus your program hangs at that point.
Your analogRead() doesn't want to be in the constructor, anyway, since that will only execute once when the object is constructed.  Instead you want to have analogRead() called at the point you need to get the analog value. In your code that would be at the start of int Pot::getValue().


text:
My ESP8266-01 doesn't want to respond to AT command after a successful flash!
Well hello, experts,
I've been trying to fix my issue all time, but all in vain.
I have an Esp8266-01 with 1MB memory. I've flashed it with an official AT firmware V2.0.0 of espressif with the help of this tutorial-arduino as a usb/TTL-: "https://www.allaboutcircuits.com/projects/flashing-the-ESP-01-firmware-to-SDK-v2.0.0-is-easier-now/", and it was a successful flash.
However, when trying to send AT commands in the serial monitor at different baud rates nothing happens.
I'll provide you with all the information down here:

Schematic for both flash and normal mode:

I used the official flasher tool from espressif
I used both Arduino IDE and Termite with no results
I've uploaded the blink sketch successfully into my module, but it never runs and blinks.
After lots of tries and resets I started to receive some information:

But still no answers from this module!!!
Could you help me, please?

The tutorial is to flash SDK 2.0 AT firmware. The AT 2.0.0 firmware is build with RTOS SDK. The 2.0 AT firmware available on Espressif site was build with settings not compatible with esp-01. It is built for 2 MB flash and  communicates over pins 13 and 15.
The latest NonOS SDK AT firmware is 1.7.1 (SDK 3), but it requires 2 MB flash too. It is possible to flash it to 1 MB module with the 2MB-c1 parameter with esptool.py. (The OTA update command will not work.)
GitHub user loboris (Boris Lovosevic) builds customized versions of AT firmware with SDK 3 for all flash sizes. You can download the files from his ESP8266_AT_LoBo GitHub repository. If you can't run his flash.sh utility, then for 1 MB flash you can Flash Download Tool with bin/upgrade/esp8266_AT_1_2.bin file and the right addresses for 1 MB flash: boot_v1.7.bin on 0x0; esp8266_AT_1_2.bin on 0x01000; esp_init_data_default.bin on 0xfc000 and blank.bin on 0x7e000 and 0xfe000.

Comments are not for extended discussion; this conversation has been moved to chat.

You need pullup resistors, 10kΩ or so, on both the NRST and GPIO0 lines. After you press and release the reset button the NRST line will be floating, and its voltage (and logic level) will be undefined. It's not unusual to see the behavior of a board change just by waving your hand over it if you leave inputs floating, so it's not surprising that you will sometimes get it to work.

Thanks for this great help, and I'll give it a try right away.

I just noticed that the TX/RX connections are incorrect. The TX from the Arduino should have the voltage divider and should feed into RX on the ESP-01. The TX from the ESP-01 should be connected to the RX on the Arduino. Ideally you would have a proper level translator between the 5V Arduino and the 3.3V ESP-01, but this might work.

Ah, never mind that last comment. It looks like you must be using the ESP-01 in place of the Arduino microcontroller. I initially thought that you were using the Arduino microcontroller to talk to the ESP-01.

That's it, I used the arduino board as a bridge in order to communicate with my esp8266.


text:
ESP8266-01 Serial.print returns a blank given a valid string
I am currently trying to create a led matrix with ws2812b leds. I am using an uno on the rear of the display to control the leds and now I want to add wifi capabilities. Since I already had serial control implemented into the uno, I decided to use an ESP8266-01 to take wifi commands and then send them via serial to the uno. The problem is that no matter what I send to the ESP, it always prints a blank to to the uno.
The code for the ESP:

#include <ESP8266WiFi.h>

// config: ////////////////////////////////////////////////////////////

#define UART_BAUD 9600

#define MODE_AP // phone connects directly to ESP
//#define MODE_STA // ESP connects to WiFi router

#define PROTOCOL_TCP
//#define PROTOCOL_UDP

#ifdef MODE_AP
// For AP mode:
const char *ssid = "LedSign";  // You will connect your phone to this Access Point
const char *pw = "aaron"; // and this is the password
IPAddress ip(192, 168, 0, 1); // From RoboRemo app, connect to this IP
IPAddress netmask(255, 255, 255, 0);
const int port = 6969; // and this port
// You must connect the phone to this AP, then:
// menu -> connect -> Internet(TCP) -> 192.168.0.1:9876
#endif

boolean led = false;

String message;

//////////////////////////////////////////////////////////////////////////

#ifdef PROTOCOL_TCP
#include <WiFiClient.h>
WiFiServer server(port);
WiFiClient client;
#endif

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);

  delay(500);

  Serial.begin(UART_BAUD);

  #ifdef MODE_AP
  //AP mode (phone connects directly to ESP) (no router)
  WiFi.mode(WIFI_AP);
  WiFi.softAPConfig(ip, ip, netmask); // configure ip address for softAP
  WiFi.softAP(ssid, pw); // configure ssid and password for softAP
  #endif

  #ifdef PROTOCOL_TCP
  Serial.println("Starting TCP Server");
  server.begin(); // start TCP server
  #endif

  for (int i = 0; i < 10; i++)
  {
    Serial.println("Booting up");
    delay(100);
  }

}

void loop() {

  #ifdef PROTOCOL_TCP
  if(!client.connected()) { // if client not connected
    client = server.available(); // wait for it to connect
    if (led){
      pinMode(LED_BUILTIN,LOW);
      led = false;
      delay(100);
    }
    else
    {
      pinMode(LED_BUILTIN,HIGH);
      led = true;
      delay(100);
    }
    return;

  }

  // here we have a connected client

  if(client.available()) {
    String message;
    long time = millis();
    Serial.println("Message Recieved: ");
    while(client.available()) {
      message = client.readStringUntil('\n'); // read char from client (RoboRemo app)
      message.trim();
      //message+=c;
      if (millis()-time >= 200)
      {
        break;
      }
    }
    client.print("You typed: ");
    client.println(message);
    pinMode(LED_BUILTIN,LOW);
    delay(400);
    pinMode(LED_BUILTIN,HIGH);
    delay(400);
    pinMode(LED_BUILTIN,LOW);
    // now send to UART:
    delay(10);
    message.trim();
    message = message + '-';
    Serial.println(message);
    //Serial.println(message);
  }
  /*
  if(Serial.available()) {

    // read the data until pause:

    while(1) {
      if(Serial.available()) {
        buf2[i2] = (char)Serial.read(); // read char from UART
        if(i2<bufferSize-1) i2++;
      } else {
        //delayMicroseconds(packTimeoutMicros);
        delay(packTimeout);
        if(!Serial.available()) {
          break;
        }
      }
    }
    */
    // now send to WiFi:
    //client.write((char*)buf2, i2);
    //i2 = 0;
  //}
  #endif

}

The code for the uno (just for testing functionality of ESP, no leds):
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(13,OUTPUT);
  digitalWrite(13,LOW);
}

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

  if(Serial.available() > 0)
  {
    String message = Serial.readStringUntil('-');
    message.trim();
    Serial.print("The message was: ");
    Serial.println(message);
    digitalWrite(13,HIGH);
    delay(200);
    digitalWrite(13,LOW);

    if (message.equals("h"))
    {
      for (int i = 0; i < 10; i++)
      {
        digitalWrite(13,HIGH);
        delay(50);
        digitalWrite(13,LOW);
        delay(50);
      }
    }
    Serial.flush();
  }

}

I have confirmed that the ESP is reading the data from TCP by having it print the string back at me. I know that the ESP is attempting to send the data because the led blinks indicating it triggered the if statement. I know that the uno is getting something over serial becasue the serial lights flash, the builtin led flashes (my code), and the uno prints back what it got to serial (though that is just a blank).
What the uno prints /
14:15:03.495 -> The message was:

I am at my wits end with this so any help is greatly appreciated.

When you print the String "The message was: " on the UNO, where do you read it? On your serial terminal? But then the Serial port is connected with the terminal over USB and also to the ESP via the pins 0 and 1. I fear that can not work. You can not connect two endpoints to the same serial port.  As the UNO has only 1 hardware serial. You have to use a SoftwareSerial to communicate with the ESP. Or you do not use the connection to the serial terminal on the PC. And access the returned string over the network connection by reading from serial on the ESB..

Yeah using software serial was a good point although that did not appear to be the issue. Is there anything else that this could be? I am still getting the same serial result on my computer.

Yes, there are more issues. But I must know, how you implemented the SoftwareSerial solution before I can give you an answer. I don't know which problems you has been solved with that solution.

I fixed the problem. My baud rates were mismatched. Thanks for the help.


text:
SIM868 AT+CIPGSMLOC returns latitude and longitude location as 0.000000
I am unable to get any location data from SIM868 module using the command
AT+CIPGSMLOC=1,1
It returns 0.000000,0.000000,2019/12/23,08:50:39

I have internet enabled using AT+SAPBR=1,1 command.
However I get proper location data when I use the command AT+CLBS=4,1
Havent found any relevant info in the AT command Manual v1.10.
I had AT+CIPGSMLOC=1,1 command working correctly on a sim800L module.

Not enough satellites. Take it outside or put it in a window.

AT+CIPGSMLOC command is used to give gsm location which gives a location as soon as internet is connected. This location is very coarse and is believed to be the location of a cell tower. Which means it has no connection with satellites.


text:
Arduino IDE gives elf but does not give hex file
Arduino IDE give .elf file but does not generate .hex file.
Show verbose output during: compilation is already selected.
/Users/username/Library/Arduino15/packages/Seeeduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-size -A /var/folders/_6/5v2q3kbs09b7fhtpnxj_zgt00000gn/T/arduino_build_274647/kuzu.ino.elf
Thanks...

Why do you assume that you should get a hex? Not all boards need a hex.

Hmmm What will I upload it than without bootloader.

You are right @Majenko can you please help how to upload it to board? When I try to upload bin.

Depends what your programmer and the programming program expects.

As I learnt, It does not generate .hex file for some board. If I change board in Arduino IDE it gives .hex file. It is something about CPU. Thanks for your answers

Arduino IDE can generate .hex file. The menu choice is Sketch:Export compiled binary.
Two files are created:
your_sketch_name_.ino.standard.hex
your_sketch_name_.ino.with_bootloader.standard.
The second one contains the basic bootloader as well.
Both are stored in the your_sketch_name directory that the IDE compiles and saves in to.
Edit: If you are using a non-AVR uC, I don't know if the command works - or exists even.

it is not about AVR boards. the command in question contains ARM compiler

The path contains ARM, is that why you imply it is not about the Arduino IDE?

@CrossRoads arm boards, work out without the Arduino IDE, are usually programmed with a bin or elf file, not a hex.

So the question needs clarification then.

I imply that "Export" will not generate a hex file and a 'with_bootloader' hex if the selected board is from a package that doesn't use hex

As I learned, It does not generate a .hex file for some board. If you change board in Arduino IDE it gives .hex file.

Repeating an earlier answer word for word is not very helpful. Please add some useful information of your own or delete the answer.


text:
Measure current across shunt resistor (Power Analysis)
I am trying to reproduce the side-channel power analysis attack described in this paper: https://pdfs.semanticscholar.org/7946/a8ee82658e2ffb017270331f220a55f5ace6.pdf for educational purposes.
The attack (on the HCS3xx family of chips) requires measuring the power consumption (i.e. current) that the chip is using in order to reveal its cryptographic key.
In the paper, they describe their setup as attaching a shunt resistor in the ground path and using a digital oscilloscope (with a sampling rate greater than 1MHz) to measure the voltage drop across this resistor.
I have reproduced this setup to the best of my abilities (pictured in the schematic below), but the problem is I don't have an oscilloscope.

simulate this circuit – Schematic created using CircuitLab
Therefore, I've decided to use an Arduino Uno I have lying around as a poor man's oscilloscope.
Besides the fact that the Arduino ADC has a much lower sampling rate (~77KHz vs. the ideal 20MHz described in the paper), I have been having an issue getting a reliable voltage reading across the shunt.
While trying to use the full 10-bit ADC, and producing samples as (ADCH << 8) | ADCL in my ADC ISR, I do not get any samples that are greater than 0.
However, when I left-align the ADC to only use 8-bit precision (with ADMUX |= 1 << ADLAR and read with just ADCH, I get non-zero values but none with a value greater than one.
Could it be that the amount of power that the chip consumes is so small that the Arduino does not have enough precision to read it? Or could it be that my shunt has too large of a resistance and is causing a reduced current throughout the circuit?

In the graphs they've got 2.5mA tops, so you've got about 2mV on that 1.2R shunt resistor.
And Uno's default ADC reference is 5V divided into 1024 steps each of them roughly 5mV. That's more than peak value of measured voltage.
And with such small sampling frequency you won't be even able to spot fast changes as you'll be measuring much slower that it needs to be.
ADC step precision can be better by using internal 1V1 reference, but it's still way too big step. And there is no other option on UNO. The Mega on the other side has also possibility to configure diferential ADC inputs and with 1x, 20x or 200x gain. But it's not supported by Arduino core, so you'll have to do it directly. However it won't help much if it's sampling too slow.

Oh I totally neglected to look at the y axis on that graph. That's very helpful. I figured that the sampling rate would be too slow but I thought that I might be able to delay starting the measurements and basically interleave multiple power traces. Probably wouldn't have worked though considering the changing counter.


text:
stray \342 in program
When I try to compile my code it says "stray '\342' in program
My code:
#include <IRremote2.h>
#include <IRremoteInt.h>

#define pinIN 11

uint32_t val;
uint32_t prev;
int fre = 0;

IRrecv remote(pinIN);
decode_results result;

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

  remote.enableIRIn();
  pinMode(2, OUTPUT);
}

void loop() {
  if (remote.decode(&result)) {
    val = result.value;
    if (val == 0xFFFFFFFF) {
      val = prev;
    }
    prev = val;
    detekceKlaves();

    remote.resume();
  }
}

void detekceKlaves() {

  switch (val, HEX) {

    case 0x807FB24D:
      Serial.println("Stisknuto PLAY");
      tone(2, fre);
      break;
    case 0x807FB04F:
      Serial.println("Stisknuto STOP");
      noTone(2);
      break;
    case 0x807F18E7:
      Serial.println("Stisknuto VOL+");
      fre += 10;
      break;
    case 0x807F906F:
      Serial.println("Stisknuto VOL-");
      fre -= 10;
      break;
    case 0x807F9867:
      Serial.println("Stisknuto OFF/ON");
      fre = 0;
      break;
    default:
      Serial.println("Stisknuta jina klavesa");

  }
}

Error code:
Arduino: 1.8.10 (Windows 10), Board: "Arduino Uno"

irTEST:43:20: error: stray '\342' in program

     case 0x807FB24D:

                    ^

irTEST:43:21: error: stray '\200' in program

     case 0x807FB24D:

                     ^

irTEST:43:22: error: stray '\254' in program

     case 0x807FB24D:

                      ^

irTEST:47:10: error: stray '\342' in program

     case 0x807FB04F:

          ^

irTEST:47:11: error: stray '\200' in program

     case 0x807FB04F:

           ^

irTEST:47:12: error: stray '\255' in program

     case 0x807FB04F:

            ^

irTEST:47:23: error: stray '\342' in program

     case 0x807FB04F:

                       ^

irTEST:47:24: error: stray '\200' in program

     case 0x807FB04F:

                        ^

irTEST:47:25: error: stray '\254' in program

     case 0x807FB04F:

                         ^

C:\Users\maxim\Documents\Arduino\irTEST\irTEST.ino: In function 'void detekceKlaves()':

C:\Users\maxim\Documents\Arduino\irTEST\irTEST.ino:43:5: warning: overflow in implicit constant conversion [-Woverflow]

     case 0x807FB24D:

     ^~~~

C:\Users\maxim\Documents\Arduino\irTEST\irTEST.ino:47:5: warning: overflow in implicit constant conversion [-Woverflow]

     case 0x807FB04F:

     ^~~~

C:\Users\maxim\Documents\Arduino\irTEST\irTEST.ino:51:5: warning: overflow in implicit constant conversion [-Woverflow]

     case 0x807F18E7:

     ^~~~

C:\Users\maxim\Documents\Arduino\irTEST\irTEST.ino:55:5: warning: overflow in implicit constant conversion [-Woverflow]

     case 0x807F906F:

     ^~~~

C:\Users\maxim\Documents\Arduino\irTEST\irTEST.ino:59:5: warning: overflow in implicit constant conversion [-Woverflow]

     case 0x807F9867:

     ^~~~

Multiple libraries were found for "IRremote2.h"
 Used: C:\Users\maxim\Documents\Arduino\libraries\IRremote2
exit status 1
stray '\342' in program

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Please help

possible unprintable characters ... copy the code from your question above and try to compile it

As @jsotola said, copy the code.  First try cutting and pasting into a new file.  If that does not work, copy it by retyping it into a new file.   How did you get unprintable characters?  Probably the best way (also difficult for a new developer) would be to find and use an octal editor to find and remove the problematic characters.

use something like notepad++ for editing

If I copy your provided code in a vim-editor you can see some strange characters. <202c>
switch (val, HEX) {
  4
  5     case 0x807FB24D<202c>:
  6       Serial.println("Stisknuto PLAY");
  7       tone(2, fre);
  8       break;
  9     case <202d>0x807FB04F<202c>:

I've removed them for you:
#include <IRremote2.h>
#include <IRremoteInt.h>

#define pinIN 11

uint32_t val;
uint32_t prev;
int fre = 0;

IRrecv remote(pinIN);
decode_results result;

void setup()
{
  Serial.begin(9600);
  remote.enableIRIn();
  pinMode(2, OUTPUT);
}

void loop()
{
  if (remote.decode(&result))
  {
    val = result.value;
    if (val == 0xFFFFFFFF)
    {
      val = prev;
    }
    prev = val;
    detekceKlaves();
    remote.resume();
  }
}

void detekceKlaves()
{
  switch (val, HEX)
  {
    case 0x807FB24D:
      Serial.println("Stisknuto PLAY");
      tone(2, fre);
      break;
    case 0x807FB04F:
      Serial.println("Stisknuto STOP");
      noTone(2);
      break;
    case 0x807F18E7:
      Serial.println("Stisknuto VOL+");
      fre += 10;
      break;
    case 0x807F906F:
      Serial.println("Stisknuto VOL-");
      fre -= 10;
      break;
    case 0x807F9867:
      Serial.println("Stisknuto OFF/ON");
      fre = 0;
      break;
    default:
      Serial.println("Stisknuta jina klavesa");
  }
}

@ MaximMaximS, you copied the code from someplace with right-to-left text orientation like an arabic website ... the hex 202d is a unicode character that controls the direction of the text ... https://www.codetable.net/hex/202d

Thanks, but I didn't copy it. I wrote it.


text:
Dim 4k LCD panel in response to ambient light
Warning: I'm completely new to Arduino, and not even sure if it's the right solution here.
I'm trying to make a better digital picture frame. Got almost all the way there by just buying a nice flat-bezel 4k display, connecting a chromecast, and putting a picture frame on it. Voila!
But I want it to adjust its brightness in response to ambient light -- and turn itself off when the room is dark. So now I need something to check a light sensor and control screen brightness.
Is it possible (and does it make sense) to disassemble the monitor, wire up the LCD panel to a controller with arduino, add in a light sensor, and try to tackle it that way? Is there a better way?
Would greatly appreciate any recommendations / suggestions / ideas.
Thanks!

maybe the display already has an auto-brightness function

check if the display allows lan remote control

Does the display have any button or such for controlling the brightness?

Well,you might need to provide an image or specs of this LCD, but assuming the worst case that it's just a basic LCD screen you will need to disassemble it and you will make a lot of things and It may be hard for you, as you said that you are completely new to Arduino.


text:
What is the best way to replace the buttons inside a car remote chip so that it can be controlled via Arduino?
I have a car remote that looks like the following

I would like to replace the buttons with some sort of switch or relay that can be programmatically controlled via an arduino unit. Would a simple relay switch work if I de-solder the buttons? Any help would be appreciated. Thanks!

you do not have to remove the switches ... you can just bridge them with relay contacts ... it may also be possible to do this without relays .... measure the voltage between ground and each side of the switch ... use battery negative terminal as ground ... post the result

@jsotola Thanks, I will post it soon. May I ask what you are thinking with regards to no relays?

I currently have the device on me and am measuring the voltage. Should I be pressing the button when measuring voltage?

Thanks, I will do that, is the point is to find sets are the input/output terminals and how much voltage it is taking in? Should I contain a current or resistance reading as well?

I measured it, and found that the voltage was 2.97 V from a black probe placed on negative battery side and a red probe on one of the 4 contacts (the one across from it read 0). The voltage of the battery itself was found to be 3.01 V.  Thank you

the 2.97 V pin is most likely the data pin ... it probably has a pullup resistor to +V  .... pressing the switch shorts the input to ground .... you can use a transistor in an open-collector configuration to short the input to ground ... the switch does not need to be removed ... you could solder a wire to one of the round test pads

Will I create problems if I directly use a switch to bridge the two pins of the button without a resistor? Thank you for the config, how can i tell which test pad is the right one?

the button directly bridges the two pins when you press it   .......... there is only 10 test pads ... use the voltmeter and press a button

Thank you, I believe I found it. The battery provides 3 V, while my arduino has 3.3 V. Do you think using 3.3V instead of the battery will create issues?

probably nor, but it is not possible to be absolutely certain without seeing the datasheet for the control chip


text:
Hook Arduino up with thermal printer and power both externally
Disclaimer: I have no connection to adafruit.
A friend and me want to build a little project. We want to connect an arduino to a thermal printer and then print out little fortune-cookie like messages, when a button is pressed. The whole setup should not be stationary and thus we need external, mobile power like batteries.
Since this is our first time using an arduino as well as a thermal printer and we have no clue about electronics, I am asking for help to set everything up without frying the arduino or the thermal printer.
We are using a standart arduino uno rev3 and the Adafruit Tiny Thermal Reciept Printer.
First question: Setting up the power supplies
So the idea was to power the arduino via a 9v battery pack to it's 2.1mm DC port. I think this should work, right?
What I am confused about is the Adafruit Tiny printer. It says it takes 5-9 V, 1.5-2A. Can I just hook up a 9V battery packand clip the caples to the printer? Or what setup do I need so that the printer will recieve enough amperes when printing?
And how would I connect both tools to a single ( larger ?) battery pack?
So that we can turn the power off easily?
Second question: Finding a good button compatible with an arduino and setting it up in the project.
So we have a gerneal idea of how things should work. Somehow we need to connect the button to the arduino which then can register a click via one of it's pins. This click I can then register with my code and from there on things get easy for me. But getting to this point is hard for us.
We don't know which buttons will work and neither how to connect it to the right pin. Which pin should we adress? Digital? Analog?
Does the button need an external power supply as well? Since otherwise the arduino would not register a change of current on a pin, right? Or do we need to connect the button to the whole circuit?
I do a lot of high language engineering and have no real idea about circuits and electronics and my friend is more of a craftsmen so we really appreciate your ideas, setups and help in general!
I am not sure if this is too much to ask but a sketch of the whole setup with a single power source and button would be awesome! Thanks. Really!

I'd suggest getting a USB powerbank that can supply 2A. A 9V battery can't supply that much current.

Also check out the Adafruit guide

Setting up the power supplies

As Gerben already stated in the comments, a 9V block battery isn't capable of supplying enough current for the thermal printer, so you cannot simply use one of them (these are meant for low power applications, like a smoke alarm). There are many different types of batteries, that you can use for this. Probably some kind of LiPo or LiIon pack would be suitable. (I'm sure you can find information about pros and cons of different battery types on the web). But the easiest way for you would be an USB power bank, that can supply at least 2.5A. A power bank incorporates mostly a LiIon pack and also already the mandatory smart charging electronics (to charge and discharge correctly and also to monitor the charge level), and - every important - a 5V voltage regulator. You can supply the 5V from the USB power bank directly to the Arduino and thermal printer in parallel. If you need to switch them on and off together (and the power bank doesn't already incorporate some kind of switch), you can use a simple switch between the positive lead from the power banks USB port and the positive leads for Arduino and printer.

Finding a good button compatible with an arduino

Every normal button is compatible with Arduino. A button is nothing more as a switch, that automatically opens again, if you are not pressing it. Just two pieces of conductive material, that get's pressed together, if you press the button. A normal button has 2 pins (you might see more pins on the button, but mostly some of these are electrically connected together, so that you effectively have only 2 pins). Connect one pin to ground and the other to a digital input pin of the Arduino. Then in your sketch use pinMode(pin_number, INPUT_PULLUP); in your setup() function. This will enable the Arduinos internal pullup resistor, which pulls the pin to HIGH, if the button isn't pressed. If you press the button, the pin will be pulled to LOW. Keep this inverted logic in mind (LOW means pressed, HIGH not pressed).
There are also many button examples for Arduino on the web, since using a button is the second thing to learn with Arduinos (after blinking an LED). Button example code via digitalRead() is also incorporated into the Arduino IDE (look for examples in the menu).

a sketch of the whole setup

Even, if someone wanted to write the code for you (and this is not a free coding service, so you cannot expect someone to simply do it), you haven't given us enough information, what behavior you want. But please don't add that here, to get this free code. What you are asking (single power source and button) is not difficult. Surely - currently you don't know much about this stuff, but it's not rocket science and there are many many Arduino tutorials on the web to help you. About the code for the thermal printer: Adafruit always provides dedicated guides for the devices they sell. There you can find a description, how the device works and is connected and used. They also provide example code and in most cases complete Arduino libraries, that hide most of the complexity of a task.
You should start by connection the Arduino to the power bank. Then you should go on and get the button going (you can write a sketch to turn the onboard LED on and off with it to learn how it works). Then you can connect the printer. Try adafruits example code. If it works, you can extend your sketch with the printers code.

Note: Some power banks turn of the power completely, if only a small current is flowing out of if. With such a power bank your Arduino might turn of as the power bank cuts the power. It normally does not draw enough current for the power bank. I think this shouldn't happen, when the printer is connected, but this depends on the current, that it draws (considering the minimal current, that it draws while idling), and the current, that is the minimal limit for your specific power bank.

Thanks for your answer! I wasn't asking for a code solution! I want to figure that out myself. Thanks for all the insight, highly appreciated.


text:
Serial Monitor is printing out weird values and skipping strings
I am currently working on a project with some friends. In short, we want to create a setup where when a button is pressed a thermal printer prints out a random sentence.
I am currently trying to get my code to work and to debug it with the Serial Monitor, but it prints out weird stuff.
The baud rate is the same for the monitor and the Serial.begin().
int checkSum[] = {-1, -1};

String stringPool[] =
                      {
                        "Satz 1", "Satz 2",
                        "Satz 3", "Satz 4",
                        "Satz 5", "Satz 6",
                        "Satz 7", "Satz 8",
                        "Satz 9", "Satz 10",
                        "Satz 11", "Satz 12",
                        "Satz 13", "Satz 14",
                        "Satz 15", "Satz 16",
                        "Satz 17", "Satz 18",
                        "Satz 19", "Satz 20",
                        "Satz 21", "Satz 22"
                      };

String chooseRandom ()
{
  bool isMaybeThreeTimes;
  int randomInt;

  do
  {
      randomInt = random( 0, sizeof( stringPool ) -1 );

      // first and further random number chosen
      if( checkSum[0] == -1 ) { checkSum[0] = randomInt; }
      else
      {
        checkSum[1] = checkSum[0];
        checkSum[0] = randomInt;
      }

      if( randomInt == checkSum[0] && randomInt == checkSum[1] )
      {
        isMaybeThreeTimes = true;
      }
      else
      {
        isMaybeThreeTimes = false;
      }

      Serial.print("Current random value: " + randomInt);
      delay(1000);
      Serial.print("Last random value: " + checkSum[0]);
      delay(1000);
      Serial.print("Last last random value: " + checkSum[1]);
      delay(1000);
      Serial.print("Three times in row?: " + isMaybeThreeTimes);
      delay(1000);

   } while ( isMaybeThreeTimes );

  return stringPool[randomInt];
}

void buttonPressed()
{
  String stringToPrint = chooseRandom();
  // Send the string to the adafruit printer.
  Serial.println(stringToPrint);
}

void setup()
{
    Serial.begin(19200);
    delay(2000);
    Serial.println("Setup finished");
    randomSeed(analogRead(0));

}

void loop()
{
    buttonPressed();
}

Any ideas why this is happening? I switched the baud rates changed delays and changed the places on where and how often and in which frequeny the method buttonPressed() is called.
Here a picture of the output:

sizeof( stringPool ) is not what you guess, if you want 22 or a similar number.

"Current random value: " + randomInt; only works if randomInt is 0, and does never append something to the text, but increases the pointer to that text, which looks like truncating the first characters.

int checkSum[] = {-1, -1};

const String stringPool[] = {
                        "Satz 1", "Satz 2", "Satz 3", "Satz 4",
                        "Satz 5", "Satz 6", "Satz 7", "Satz 8",
                        "Satz 9", "Satz 10", "Satz 11", "Satz 12"
                      };

const String& chooseRandom () {
  bool isMaybeThreeTimes;
  int randomInt;

  do {
      randomInt = random( 0, sizeof(stringPool) / sizeof(stringPool[0]));
      isMaybeThreeTimes = (randomInt == checkSum[0] && randomInt == checkSum[1] );

      Serial.print("Current random value: "); Serial.println(randomInt);
      delay(1000);
      Serial.print("Last random value: "); Serial.println(checkSum[0]);
      delay(1000);
      Serial.print("Last last random value: "); Serial.println(checkSum[1]);
      delay(1000);
      Serial.print("Three times in row?: ");
      Serial.println(isMaybeThreeTimes?"Yes":"No");
      delay(1000);
      checkSum[1] = checkSum[0]; // for next run
      checkSum[0] = randomInt;
  } while (isMaybeThreeTimes);
  return stringPool[randomInt];
}

void buttonPressed()
{  // has nothing to do with button presses, just a test
  const String& stringToPrint = chooseRandom();  // waits 3 seconds
  // Send the string to the adafruit printer.
  Serial.println(stringToPrint);
}

void setup() {
    Serial.begin(19200);
    delay(2000);
    Serial.println("Setup finished");
    randomSeed(analogRead(0));
}

void loop() {
    buttonPressed();
}

Some fixes, not tested.
Edit: some more fixes, tested.

Thanks. Would you mind explaining what was wrong with my code?

see my comments to your post. Mainly you have a strange idea about the + operator. "Hello" +1 is "ello" of course :)

Oh I see. I thought I could contencate the int and the string with the + operator. I haven't worked with c++ or c yet ( not sure what language is used here ) and have not a lot of training working with pointers ( the &/* stuff).
I just used my Java background and tried to get it to work. I will better look into some syntax tutorials for arduino! Thanks again.

it's c++ and the main difference to Java is that you should not: use Arduino String objects for texts.


text:
Adafruit thermal printer prints weak
I am currently hooking up my arduino to an adafruit mini thermal printer. When a button is pressed, some code is executed which then sends some information to the thermal printer.
Everything works fine except the thermal printer print is very weak and can barely be seen as soon as the printer needs to print more than 3-5 chars. Any ideas why? Both, the arduino and the thermal printer are hooked up to 9V batteries.
Here is the code
#include "Adafruit_Thermal.h"

// Here's the new syntax when using SoftwareSerial (e.g. Arduino Uno) ----
// If using hardware serial instead, comment out or remove these lines:

#include "SoftwareSerial.h"
#define TX_PIN 6 // Arduino transmit  YELLOW WIRE  labeled RX on printer
#define RX_PIN 5 // Arduino receive   GREEN WIRE   labeled TX on printer

SoftwareSerial mySerial(RX_PIN, TX_PIN); // Declare SoftwareSerial obj first
Adafruit_Thermal printer(&mySerial);     // Pass addr to printer constructor

int buttonIn = 8;
int val = 0;

void setup() {
  pinMode(7, OUTPUT);
  digitalWrite(7, LOW);

  pinMode(buttonIn, INPUT);

   mySerial.begin(19200);  // Initialize SoftwareSerial
   //Serial.begin(19200); // Use this instead if using hardware serial
   printer.begin();        // Init printer (same regardless of serial type)
}

void loop() {
  // put your main code here, to run repeatedly:
     val = digitalRead(buttonIn);
     if(val == HIGH)
     {
        printer.println("test");
        printer.sleep();      // Tell printer to sleep
        delay(3000L);         // Sleep for 3 seconds
        printer.wake();       // MUST wake() before printing again, even if reset
        printer.setDefault();

     }
}

Did I set up anything false? Is the power supply not enough?
The adafruit was sent with a selftest from the seller where everything seemed to be fine.
Left, seller test, second from left, my selftest, third and fourth from left are example printer and charset tests.

And here you can see how everything is wired together.

Thank you very much!

the problem is always the 9 V battery

9V batteries are utter $%^*. The printer needs a proper power supply (2A) or some big meaty high current bateries (lithium rechargeables).

The datasheet states:
Requires 5-9VDC @ 1.5Amp power supply during print.
In my experience this printer provides best results when operated at its upper limit. I am using a 9V 2A power supply for that. A bettery is definitiverly not enough.

So how would I provide a mobile power source? Many people state that powerbanks aren't a sufficient power source either.

There are beefy powerbanks that can provide up to 3A @ 5V. Those are not cheap and sadly most powerbanks do not provide the current that is printed on the case. I'd suggest you use batteries for RC cars. These are beefy and you will find a model that provides around 7.2V. Which perfectly fits in the range of the printer.

Just an example: This Battery can provide up to 40A. (2Ah * 20C = 40A) So you might get away with a smaller one.

The keyword here is Li Ion or a LiPo battery (the one linked by Kwasmich is a Li Ion battery). These are used in high power applications like drones, so with these you are good to go. 9V block batteries are for low power projects, nothing more.

@chrisl Okay thank you all. I'll definitely look into Li Ion and LiPo batteries. I want to use a small power source since the whole build should be portable in a box. I got a powerbank that can output 2.1A / 5V. Would this be sufficient?

5-9 V and 1.5 A? Sounds like a job for a 2s2p 18650 setup.

In theory, yes. But my experience is that the voltage breaks down to around 4V at this current. So the answer is most certainly: NO.

Okay, I hooked up the powerbank directly to the thermal printer. The print is way better now and sufficient for my needs. Thanks guys!

Proper care of your thermal transfer printer is critical to keeping it at peak performance for as long as possible. Keep reading for five tips to keep your thermal transfer printer running optimally so you don’t have to spend on unnecessary new parts or wasted media down the line.

Maintain The Right Heat And Speed Ratio
These two things are true:

High print speeds can improve throughput
Higher heat increases the darkness of your print and therefore the contrast of your barcodes.
However, the wrong ratio can lead to print issues and even damage your printhead.
We generally recommend running your printer on a relatively slow setting. This uses less heat and ensures a crisp, clear printed image. On a similar note, we recommend you avoid increasing heat settings without guidance from a professional.
If you work with a supplier who sets up and tests your printer with your media prior to shipping it to you, they have likely adjusted the heat and speed ratio to one suitable for your application.
Maintaining a proper heat and speed ratio will ensure a scannable barcode and extend the life of your printhead so you can avoid costly waste and unnecessary part replacements.

Keep The Print Head Clean
Keeping your print head clean is imperative to maintaining your printer. Without regular cleaning, your print head will be more susceptible to abrasion during printing. This can reduce image quality and shorten the life of your printer.

We recommend you establish a schedule for regular print head cleaning. Our technical team endorses cleaning this part whenever you replace the label roll or install a new ribbon.

Protect The Print Head From The Media
To safeguard the print head against abrasion, use a thermal transfer ribbon that’s slightly wider than the media.

Don’t Use Razor Blades Or Box Cutters
Unless you’re using a model with a peeler or applicator, you should only use tools such as the printer’s tear bar or scissors to remove labels. Razor blades, box cutters, and other inappropriate tools can easily slip and cut the driver roller. These cuts can create voids in your printed labels leading to misreads.

Avoid “Ribbon Wrinkles”
If you’re seeing seemingly random diagonal lines on your print you’re probably dealing with ribbon wrinkles. The main culprit of ribbon wrinkles is too much heat, so your first option is to lower the heat setting. If that doesn’t work, make sure your printer is set up properly. Check that the ribbon is loaded correctly, the media guides are set properly, and the head pressure is balanced. If you’re still experiencing issues you might want to reach out to your supplier to ensure your media and ribbon combination is ideal.

Regards,
Peter

whenever you replace the label roll or install a new ribbon ... Avoid “Ribbon Wrinkles” - what ribbons are you referring to? Thermal printers don't have ribbons. We recommend you establish a schedule - who is "we" here? Are there two Peter Grofts?


text:
Is it possible to get values only during vibration/movement from an Accelerometer(ADXL335/MPU6050)?
I'm trying to make a wearable motion sensor using ESP32 board and ADXL335 Accelerometer.
Presently when I'm serial printing the output I'm getting the tilt value as well, which have different values at different orientation (I'm printing average of the X,Y & Z). So when I try to light up an led by setting a threshold the average value is different in different orientation.
Is there way to get values only during vibration and be zero when there is no vibration/body movement.
Thanks in advance guys for the help.

i think that your question needs to be about recognizing movement

Yes.
Linear Acceleration at given axis = Actual Acceleration - Gravitational Acceleration
Gravitational Acceleration across any Axis = Magnitude of Gravity Vector x Cosine of axis angle with the Gravity Vector


text:
Record stereo audio from two Bluetooth headsets
I've been playing with Arduino for a few years, but I'm new to Bluetooth and streaming audio.
I'd like to develop (or assemble or buy) a device for recording stereo audio from a pair of Bluetooth headsets to a lossless file format on a micro SD card. I'm thinking this would be great for recording a podcast on the go with two people.
I'm guessing an ESP32 or similar could relatively easily record mono audio to an SD card.
Questions:

Any recommendations on libraries and/or tutorials that could be used to piece together audio recording from a Bluetooth headset mic to lossless audio file on micro SD card? I'm thinking at least this first step should be relatively straightforward. :)
Any suggestions on how to integrate two stream of mono audio from two Bluetooth headset mics in order to combine to a single stereo audio file (using the streams as left and right channel)? I think this would require two Bluetooth receivers, and streaming the audio from each to a third processor for combining and saving the streams to a single stereo file. But again I'm interested in libraries, frameworks, etc.

Thanks so much!!

you basically need a real computer for this, not an MCU. it's easy to combine two mono tracks into a stereo file in audacity, so just record the pod in mono on each phone and export.

I realized this later in the day, a Raspberry Pi or similar computing platform would be needed. I was thinking there might be an external audio processing board I could use, but better to just use R Pi with USB audio interface or similar.
I don't want to record separately and combine because I don't want to have to manually allign the audio clips every time.


text:
Help with tachometer programme
This is my first programme, which is to control a brushless ESC motor and an IR sensor to read the props' RPM. However I can't seem to figure out why it's not working. The reading keeps giving me 0, and after I edited the programme by changing while (millis()-start < 60000);to while (millis()-start < 1000);, it feeds me expected ';' before '{' token on if (start > millis(){, which makes no sense whatsoever. Here's the programme:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>

//Display&sensor
#define Backlight_Pin 13
int initial=0;
//int REV=0;
//int prevtime=0;
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

//ESC
Servo ESC;     // create servo object to control the ESC
int potValue;  // value from the analog pin

//Calculation
int sensorvalue;
int state1 = HIGH;
int state2;
float rps;
float rpm;
long prevMillis = 0;
long interval = 200;
long currentTime;
long prevTime = 1;
long diffTime;
int sensorthreshold = 1;
int Sensor = 8;
int photoPin = 2;               //
int val = 0;
int valold = 0;
int start;
unsigned int count = 0;

void setup() {
  pinMode(Sensor,INPUT);
  valold = digitalRead(photoPin);
  lcd.begin(16, 2);
  lcd.clear();
  ESC.attach(9, 1000, 2000);
  Serial.begin(9600);
}
void loop() {
  if (initial==0)
  {
    lcd.setCursor (6,0);
    lcd.print("RPM:");
    lcd.setCursor (0,1);
    initial=1;
  }
  //REV= digitalRead(Sensor);
  //lcd.print(REV);

  //Calculation
 start = millis(); // take the start time
 count = 0; // reset couter
 // do the following loop for 60000ms = 1min
 while (millis()-start < 1000);
 {

    if (start > millis(){
      start = millis();
      count = 0;
    }
   val = digitalRead(photoPin);
   if (val==LOW)
   {
     digitalWrite(ledPin, LOW);
   }
   else
   {
     digitalWrite(ledPin, HIGH);
     if (val <> valold) {
       count ++;
       valold = val;
     }
   }
 }

      lcd.print("RPS = ");
      lcd.setCursor(7,1);
      lcd.print(count);
      delay(1000);
      lcd.setCursor(0,1);
      lcd.print(" ");

//ESC
  potValue = analogRead(A0);   // reads the value of the potentiometer (value between 0 and 1023)
  potValue = map(potValue, 0, 1023, 0, 180);   // scale it to use it with the servo library (value between 0 and 180)
  ESC.write(potValue);    // Send the signal to the ESC
}

And if I put ";" in front of "{", I get this error

expected primary-expression before '{' token

How could I fix this? Any help is appreciated. Thanks!
p.s. I had a rig holding the sensor and rotor stationary and waited 5 minutes for results, no luck, so I thought I would change the time to 1 second and measure RPS, then manually time the result by 60, but then the code broke. I don't think it was hardware failure as almost all joints are soldered, and the wires are solid copper.

You habe a missing closing bracket ) in the first if condition inside the while loop. Likely that caused the problem. Remove the extra semicolon, that you put in.

When the compiler is giving you errors, it has absolutely nothing to do with hardware. If the compiler shows an error, the sketch doesn't even get uploaded to the board


text:
What is the best data type to be used through i2C
i'm trying to send multiple commands to multiple slaves controlling motors. Slave Controller(Arduino Nano) will receive the command, and returns the current position of the motors to the Master(Arduino Mega).
What data type would be best to use in this scenario. I am considering, string or byte data type.

Why are you considering string? Is it going to be read by humans? I hav not heared of I2C to human interfaces. - Imagine there was an image file format based on XML. Do you think that would be efficient?

I2C is usually a one byte register address and one to four bytes of binary data (interpreted by the I2C device as a 8-bit to 32-bit bitstring). The interface is designed as a high speed, low volume, low cost command and control (master-slave) system. You should read the details at https://i2c.info/i2c-bus-specification

i plan on using string, to make the command unique. but i get your point, thankyou for pointing that out.

String as in array of characters makes sense. Using a C++ String does not make sense. I'd suggest using fixed length arrays of characters without null terminators vs. null-terminated C strings however. That might make your commands easier to read. You can also use integer enum values. That would likely make for shorter byte counts, but make the data a little harder to read if you log it to the console.

I2C works with fixed size byte arrays.
Single bytes for commands should be sufficient. For positions you might need int16_t or even bigger numbers. Unsigned positions relative to (above) zero might make things easier, eventually (?)
As you have the same architecture on both sides, mapping of byte arrays to bigger numbers via union will work well.

...or, assuming both sides speak the same 'protocol' you can use hton* and ntoh* to make your code architecture-independent.

Strings (aka byte arrays of arbitrary length) are perfect for asynchronous and full duplex protocols like UART, essentially because those are no master-slave protocols. Here, both master and slave can transmit a byte stream independent of each other at any time and with any length.
But using strings on I2C is quite uncommon. As I2C is a master-slave bus where any communication (read and write) is initiated by the master generating the bus clock, using strings has the big disadvantage, that the master has to know the number of bytes the slave has to transmit. Of course you could implement it, but as long as you don't need the data to be human-readable, I suggest the more efficient way of transmitting bytes.
Usually, an i2c read transmission is done by

addressing the slave in write mode
Writing the target value's register address
Addressing the slave in read mode
Reading an arbitrary number of bytes (e.g. four bytes for float values)

A write transmission is a bit simpler:

addressing the slave in write mode
Writing the target value's register address
Writing an arbitrary number of bytes (e.g. four bytes for float values)

This is the standard protocol that e.g. I2C sensors use and it's convenient to implement the same behaviour in the ISR when using a microcontroller (you could think of "register addresses" as "variable IDs").
To prepare values of any datatype for transmission (e.g. float to byte[4]) you can use a union.


text:
How do i send data from a Master to another Master?
I am using an ESP32 to receive data from web.
However in an I2C communication, the EPS32 does not work as a Slave and i already have an Atmega as the Master.
i have seen sites saying Master-Master I2C Connection is possible however, how do i do this? or are there other solutions to have the ESP32 communicate to the ATMega?

I don't have much experience with I2C, but there are other ways, like UART, or SPI.

Both your master devices must support Multimaster mode, i.e. Arbitration and Synchronization. See I2C Spec here for a description of the arbitration process.
It's up to you to handle a lost arbitration in your software.

or are there other solutions to have the ESP32 communicate to the
  ATMega?

Of course. As you considered I2C to be sufficient, UART and SPI are feasible alternatives supported by almost all microcontrollers.

what do you recommend i do here?
use multiple communication styles? I2C and SPI?since all i need is to have 2 master device communicate, while only the other master communicate with the slaves.

@JuliusNoelBanayo Depends on your requirements. If you only have to transmit some bytes every 100ms, I2C may be the most economic solution (Multimaster mode is supported by ESL32 and Atmega). If there's much more data and/or you need it fast, you should consider SPI.


text:
What is the best technique to design a 20 push button circuit
I will be controlling a robot with more than 10 motors which means I'll need 2 buttons each to control moving forward and backward. My controller is an Arduino mega. Is 1 pin = 1 button the best solution here? Or should I use another IC for this?

"best solution" depends on your preferences. As the Arduino Mega has enough I/O pins, you might use them without additional hardware. If you want not to rely on the board used (e.g., switch to other/faster MCU in the future), you might use I/O multiplexers like MCP23017, which gives you 16 additional I/Os via I²C, and you can use up to 8 of them on one I²C line. We actually use four of them for 61 touch switches. There are also breakout boards with these chips.

For 20 buttons you can use a Keypad Matrix arrangement (plenty of examples online) where you would use only 9 pins (5 columns of 4 rows is 5+4 pins). It's slightly more involved that simple 1:1 buttons to pins, but thankfully there is a Keypad.h library that takes the hard work out of it for you.
If you want to be able to press multiple buttons at once you need to include diodes in your matrix to prevent "ghosting".
Nick Gammon has a great writeup on it here.

Upvoted. Nice alternative ... can I assume the benefits of yours are less ICs, simultaneous input, and the benefit of mine is less input pins?

Yup. 3/4 as opposed to 9.

Yes this is actually one of my solutions in mind. Maybe apply multiple matrix no?

The more buttons you have in your matrix the more efficient it gets on pins.

The example project below can control 16 switches. If you have a membrane keypad with 5 x 4 or 5 x 5 then you can meet your requirement.

I will shortly add an example of using shift registers to have multiple inputs (the main use case of shift registers is the same)
Link

Below is the example using shift registers. You need three shift registers as @Michael mentioned in his answer. Here is one example where you can control 32 switches maximum. You are only using 3 data pins and two power pins. This is the main application of the shift register. You don't have to do any selection, whenever you read the serial input data, you will automatically get the status of all the 32 switches in one Go.

Here is the code
// File : Cascade165.ino
//
// Version 1, 5 August 2021, by Koepel
//     Initial version.
// Version 2, 5 August 2021, by Koepel
//     Layout of the wiring made better.
// Version 3, 13 August 2021, by Koepel
//     Changed 'SCK' to 'clockPin'.
//
// Cascade of four 74HC165 shift-in registers.
// Only three pins are used on the Arduino board, to read 32 switches.
//
// Using the 74HC165 is safe, because a pulse to the Latch pin
// ('PL' on the 74HC165) will make a new start every time.
// In case of an error or a wrong clock pulse by noise,
// it synchronizes the data when inputs are read the next time.
//
// Based on:
//   (1)
//     Demo sketch to read from a 74HC165 input shift register
//     by Nick Gammon, https://www.gammon.com.au/forum/?id=11979
//   (2)
//     74HC165 Shift register input example
//     by Uri Shaked, https://wokwi.com/arduino/projects/306031380875182657
//
//

const byte latchPin = 9;        // to latch the inputs into the registers
const byte clockPin = 13;       // I choose the SCK pin
const byte dataPin = 12;        // I choose the MISO pin
uint32_t oldOptionSwitch = 0;   // previous state of all the inputs

const int pulseWidth = 10;      // pulse width in microseconds

void setup ()
{
  Serial.begin( 115200);
  Serial.println( "Turn on and off the switches");
  Serial.println( "Top row is switch 0 (right) to switch 7 (left)");
  Serial.println( "Second row is 8 to 15, and so on");

  pinMode( clockPin, OUTPUT);   // clock signal, idle LOW
  pinMode( latchPin, OUTPUT);   // latch (copy input into registers), idle HIGH
  digitalWrite( latchPin, HIGH);
}

void loop ()
{
  // Give a pulse to the parallel load latch of all 74HC165
  digitalWrite( latchPin, LOW);
  delayMicroseconds( pulseWidth);
  digitalWrite( latchPin, HIGH);

  // Reading one 74HC165 at a time and combining them into a 32 bit variable
  // The last 74HC165 is at the bottom, but the switches start numbering
  // at the top. So the first byte has to be shifted into the highest place.
  uint32_t optionSwitch = 0;
  for( int i=24; i>=0; i-=8)
  {
    optionSwitch |= ((uint32_t) ReadOne165()) << i;
  }

  for( int i = 0; i<32; i++)
  {
    if( bitRead( optionSwitch, i) != bitRead( oldOptionSwitch,i))
    {
      Serial.print( "Switch ");
      if( i < 10)
        Serial.print( " ");
      Serial.print( i);
      Serial.print( " is now ");
      Serial.println( bitRead( optionSwitch, i) == 0 ? "down ↓" : "up   ↑");
    }
  }

  oldOptionSwitch = optionSwitch;
  delay( 25);      // slow down the sketch to avoid switch bounce
}

// The ReadOne165() function reads only 8 bits,
// because of the similar functions shiftIn() and SPI.transfer()
// which both use 8 bits.
//
// The shiftIn() can not be used here, because the clock is set idle low
// and the shiftIn() makes the clock high to read a bit.
// The 74HC165 require to read the bit first and then give a clock pulse.
//
byte ReadOne165()
{
  byte ret = 0x00;

  // The first one that is read is the highest bit (input D7 of the 74HC165).
  for( int i=7; i>=0; i--)
  {
    if( digitalRead( dataPin) == HIGH)
      bitSet( ret, i);

    digitalWrite( clockPin, HIGH);
    delayMicroseconds( pulseWidth);
    digitalWrite( clockPin, LOW);
  }

  return( ret);
}

Link to the shift register project: https://wokwi.com/arduino/projects/306024460940476993

there are so many versions of this shift register.     https://www.digikey.com/en/products/base-product/texas-instruments/296/74HC165/16       how do you decide which one to use?

you can use a so called shift register. One very common one is a 74HC165 shift register (https://playground.arduino.cc/Code/ShiftRegSN74HC165N/).
With one of such IC you can connect 8 buttons, however you can daisy chain max 4 to get 4 * 8 = 32 button inputs, only using 4 digital pins of the Arduino. In your case you would need 3 ICs to get 24 (thus 20) button inputs.

A shift register is not a multiplexer. A shift register shifts out all inputs, and a multiplexer selects one-of-N inputs to pass through.

@Majenko yes you are right, I fixed it (thanks)

Thats the problem i have with multiplexer. I need it able to function independently without needing to be "selected"

With this IC you don't need to 'select'', or at least you get all inputs.

@Julius With a multiplexer you program the Arduino so that it selects each button and then checks whether it is pressed, in turn. Because the Arduino is much faster than the human finger, it still sees all the button presses.

A different take
Use an app to make on-screen virtual controls instead of using physical buttons, and send press events over bluetooth or wifi or ESPNOW.
Advantages

no parts needed if you have a phone/laptop already
no soldering
no flaky parts wearing out
complete control over button layout
easy to upgrade/modify control layout based on field experience
one less part to carry
trivial to have extra backup remotes
opens the door to macros (eg. auto-land), test routines, etc
lets you log data from the robot for debugging
EASILY add cool control hardware like gamepads, voice, or camera
much easier to code buttons in, eg. HTML+JS than C++
separates programming concerns and allows detached evolution
allows possibility of internet/remote control
can be developed on laptop, moved to portable raspPi or phone
can control more than one (or a new) robot from the remote control

Disdvantages

needs code in two languages
extra part (eg. ESP8266), though buttons are expensive too
slightly increased latency (but buttons should be debounced anyway)
might not be as satisfying as a 80+ hour hand-built controller
requires a bit of security consideration (maybe)

All in all, I think the advantages FAR outweigh the drawbacks. If you need soldering practice and human-held hardware design experience, a physical remote is a decent project, but you can always do that later once you get the robot working with abstract commands; you don't have to build and debug both at the same time, which is huge to me...
If you NEED a physical remote
You can still get many of the above benefits in a physical remote if you put an MCU/SBC in the remote. Then talk to the robot with uart/wifi/bt/etc. Uart lets you run just 4 wires to the remote instead of dozens. There's lots of existing 4+wire connectors (USB-B, RJ-45, XLR, DIN, etc) that you can use for this; thin, light, cheap, replaceable. Such a config  allows serial debugging, logging, etc. It frees the robot CPU from having to deal with interrupts and library footprints.
All in all, it will make making faster for the small cost of a cheap MCU like a nano/bluepill/esp32...

Max buttons for min pins (via electrical engineering and busy wait in interupt)
Hook up each button to an interrupt and an analog pin. You can use the same interrupt and analog pins for all buttons, if you use resistors to discern between the buttons.
Use the interrupt pin to get notified, when a button is pushed. Use the resistors to have a different target voltage for each button in a voltage divider. Then in the interrupt handler use the analog pin to measure the voltage.
The main problem is that the voltage will take some time to stabilize after the interrupt already fired. I'd check for at least 3 consecutive identical readings (~30ms delay after the voltage stabilized).
Make sure you have some tolerance, e.g. by shifting at least the two least significant bits out (value = AnalogRead(PIN) >> TOLERANCE_BIT_COUNT;). With the analog pins' 10 bit resolution (1024 values, AFAIR), 2 bits lost for tolerance and an additional bit lost for difference between HI and LO (needed to trigger the interrupt), there are at least 7 bits left, which could suffice for up to 127 buttons.
Yes, you can hook up a keyboard with 2 pins, if you implement part of the logic in hardware (127 carefully designed voltage dividers) and part in software (detecting stabilized voltage). However the identification which button is pressed can be susceptible to deviations in voltage as small as 4.8 mV (a difference of 1 in the value of AnalogRead, which might carry over the tolerance). Also you can not detect multiple buttons being pushed at the same time. However if the electrical design has been carefully engineered, no failure detection may be needed for multiple buttons being pushed, because the interrupt would not fire, depending on how the target voltages stack up.
Electrical engineering problems to be solved:

Designing the voltage dividers is left to the reader, because you can crank up the tolerance, if you need less buttons. This may mitigate the susceptibility to small deviations in voltage. My proposal would be to get X identical resistors of R Ohm for X buttons. Connect the resistors in series and fork the voltage between the resistors via the buttons. Connect all forks after their respective button to the analog pin and another resistor (of X times R Ohm) to either ground or Vcc (depending on the choice of interrupt HI vs. LO). Add a pull-up/down resistor to the end of the resistors in series as necessary.
You might need to make sure not to lose too many bits too early, because otherwise there might be consecutive "identical" values without the voltage having stabilized.
Check, if the interrupt should fire for HI->LO or LO->HI, as one might offer more distinct target voltages than the other. I just assumed that the first AnalogRead will return a value of about 512 either way.
I remember that you can remap the values of AnalogRead to regain the 1 bit lost to HI-LO vs. LO-HI transition. This is not recommended as it might interfere with the behaviour of other analog pins. However in a pinch this may either double the number of buttons possible or add another bit for tolerance.
A small capacitor might help to filter bumping out of the buttons' switching action, so you don't get multiple interrupts for a single button push. However this may increase the time needed for the voltage divider to stabilize at the target voltage. So choose the smallest capacitor and resistors, you can get away with.


text:
TouchScreen GUI Reference Guide Help
Recently I have gotten some Touchscreens to add to my projects and I am very excited to use them. However, I am not sure where I can find a guide to help me create my own GUI with the touchscreens. The touchscreen I am using right now is the HiLetgo 2.4 inch TFT LCD Display Shield with a ILI9341 Driver. I have experience programming GUI's in Python and I feel fairly confident in myself that I can create the GUI's that I want if I had a resource to learn from. Please Let me know if you'd like anymore information. Thank you!

In general there's very little "GUI" programming functionality in TFT libraries. You have low-level operations mostly - things like line drawing. Making a GUI is a lot of programming.

Of course, it depends what library you are using as to what functionality you have...

Thanks for the quick response! I am nit trying to make a super complex GUI but just one that's my own. I am using the Adafruit_GFX_Library. Are there better libraries out there or is the Adafruit library okay?

You get buttons and canvases as the only "objects" you can work with. Very basic. Anything more than that you have to draw yourself.


text:
Blynk.Begin(auth, ssid, pass) causing watchdog reset
I am trying to follow this tutorial and I keep hitting a problem repeatedly. I checked in my code that every time it hits the line Blynk.begin(auth, ssid, pass);, the serial monitor shows me that there was a cause:4, boot mode:(3,6) wdt reset. I looked it up a little bit and learned that this is a "hardware watchdog reset" but I am not sure why this problem is happening. Please let me know if you guys would like anymore info. Thank you!
here is my code:
#include <ESP8266WiFi.h>

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <BlynkSimpleEsp8266.h>
char auth[] = "xxx";

/* WiFi credentials */
char ssid[] = "xxx";
char pass[] = "xxx";

/* HC-SR501 Motion Detector */
#define ledPin 7
#define pirPin 2 // Input for HC-S501
int pirValue; // Place to store read PIR Value

void setup()
{
  Serial.begin(115200);
  Serial.println("here 1");
  delay(10);
  Serial.println("here stop?");
  Blynk.begin(auth, ssid, pass);
  pinMode(ledPin, OUTPUT);
  pinMode(pirPin, INPUT);
  Serial.println("here 2");
  digitalWrite(ledPin, LOW);
}

void loop()
{
  getPirValue();
  Blynk.run();
  delay(10);
  Serial.println("here 3");
}

/***************************************************
 * Get PIR data
 **************************************************/
void getPirValue(void)
{
  pirValue = digitalRead(pirPin);
  if (pirValue)
  Serial.println("here 4");
  {
    Serial.println("==> Motion detected");
    Blynk.notify("===> Motion detected");
    Serial.println("here 5");
    delay(10);
  }
  digitalWrite(ledPin, pirValue);
  Serial.println("here 6");
}

Serial Monitor:
[6485] Connected to WiFi
[6486] IP: xx.x.x.xx
[6486]
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on ESP8266

[6492] Connecting to blynk-cloud.com:80
[6584] Ready (ping: 38ms).

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

wdt reset
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v8b899c12
~ld
here 1  (Serial.println in line 19 of code)
here stop? (Serial.println in line 21 of code)

Specs:

Board: Generic ESP8266 Module
Upload Speed: 115200
CPU Frequency: 80MHz
Flash Frequency: 40MHz
Flash Mode: DOUT (compatible)
Flash Size: 512K (no SPIFFS)
Crystal Frequency: 26MHz
Reset Method: ck
Debug Port: Disabled
Debug Level: None
IwIP Variant: v2 Lower Memory
VTables: Flash
Exceptions: Disabled
Builtin LED: 2
Erase Flash: Only Sketch
Espressif FW: nonos-sdk 2.2.1 (legacy)
SSL Support: All SSL ciphers (most compatible)

sorry, now I see the true error. you can't use io 7. it is wired to flash memory. what esp8266 board/module do you have?

Moving from io 7 to io 6 solved the error for a little bit but when the motion sensor detected motion, it restarted again with the same original error. Could my PIR sensor be causing the problem?

https://arduino-esp8266.readthedocs.io/en/latest/reference.html

Changing the io from 6 to 4 solved the problem. Thank you Juraj!


text:
Sketchy Wemos D1 mini Pro
Recently, I bought a "ThingPulse ESP2866 Wifi Color Display Kit". I bought the kit before reading the reviews and finally read them the other day. Some of the reviews seem fake but a couple of them say that the Wemos D1 mini pro is being used to "steal credit cards" and other information. The bad reviews claimed that when they plugged the wemos into a power source, a wifi network named "ESP_xxxxxx" appears and thats how their data is stolen. I plugged the Wemos that came in my kit to a power source and a wifi network starting with "ESP..." appeard. I was wondering if this is a valid concern or if its just conspiracy. I am not very informed on cybersecurity and data security so I thought this would be the best place to ask. Please let me know if you'd like anymore information.  Thank you!

It's pure conspiracy, paranoia, or people just generally not having the slightest clue what they have bought. By default the ESP8266 is in Access Point mode, and named ESP_[last 6 chars of MAC address]. It will have an IP address in the range 192.168.4.x. And that is all.
It can't do anything else until you actually program it to do something.
Part of the "problem" is probably that the ESP8266 remembers WiFi settings independently of the sketch that is running on it. It's only the WiFi settings it remembers, though - not what to do with any data that travels over WiFi. That is purely down to whatever sketch you install.
Unless you manually program it so it connects to your WiFi, or add extra hardware for other communications, the device can not, and will never be able to, send any data to anyone, anywhere, ever. Full stop.

Comments are not for extended discussion; this conversation has been moved to chat.

Before you’ve programmed the WEMOS, it will appear like an access point. It’s one if it’s great qualities of this versatile little chip. I wouldn’t worry about it. Don’t you have a secure vault for your personal info? It’s very easy to encrypt. Just search the internet on how to protect your data. You can really go it the safe way and implement a VPN. You might have to pay a 1-2$ a month for the service, which is actually a cloud based service.


text:
Arduino IDE doesn't pick up serial ports
I am fairly new to Arduinos and I recently bought a nodeMCU Amica esp2866 for this tutorial. I have my board connected to my MacBook Air (10.14.5 with Mojave) and only the "/dev/cu.Bluetooth-Incoming-Port" is the only one that shows up.

I am using a basic USB cord to connect the board to my MacBook and I know the cable isn't broken because I have used it in the recent past. If anyone knows how to fix this problem or has run into this problem in the past, please let me know. Let me know if you'd like anymore information. Thank you!

A Mac is (sort of) a Unix box.  So, try opening a console and typing in "lsusb".  I think that should list all the USB devices the computer sees.

What version of the nodeMCU are you using?

The MAC / Arduino install instructions appear to be here.
If your Arduino (possibly a NodeMCU 1.0 version board) is using the CP210x chip set there appears to be a download page here.
If your Arduino (possibly a NodeMCU 0.9 version board) is using the ch340g, ch34g or ch34x chip set there appears to be an effort to create a Mac OS X driver here.
The install instructions from that github page are as follows:

Installation
Unplug any CH34* devices.
Unload the old drivers if running:
    sudo kextunload /Library/Extensions/usbserial.kext
    sudo kextunload /System/Library/Extensions/usb.kext
Remove the old driver by issuing one of the following commands (depending on your installation):
    sudo rm -rf /System/Library/Extensions/usb.kext
    sudo rm -rf /Library/Extensions/usbserial.kext
Double-click on the CH34x_Install_V1.5.pkg file and install (no need to reboot)
Instead of rebooting, you can force quit Installer after it completes.
Load the new driver:
    sudo kextload /Library/Extensions/usbserial.kext
Plug in your device. It should now be listed under the /dev directory. Examples:
    /dev/cu.wchusbserial1410
    /dev/tty.wchusbserial14210 (driver version 1.5)