Photograph via snooOG

An unofficial place for all things Arduino!

We all learned this stuff from some kind stranger on the internet. Bring us your Arduino questions or help answer something you might know! 😉


644,396 Subscribers


How to call another variables value with a variable into a function?

Sorry for the posts recently, you guys have just been so insanely helpful and I have learned more about code in the last 72 hours than I have in 5 years of tinkering.

The Problem:

I have a bye array stored with a sunIcon PNG in it.
it looks like this:

static const byte sunIcon[] PROGMEM  = {  0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, ...

Then I can print to "sunIcon" to the screen using this, and it works great!
(note the two spots I defined "sunIcon")

int16_t rc = png.openFLASH((uint8_t *)sunIcon, sizeof(sunIcon), pngDraw);

if (rc == PNG_SUCCESS) { 
rc = png.decode(NULL, 0); 

Now I'd like to call the above in a function, where I can define the icon I would like to display in the function, here's what I have and its not working.

void showPNG(const byte a[]){

  int16_t rc = png.openFLASH((uint8_t *)a, sizeof(a), pngDraw);

  if (rc == PNG_SUCCESS) {
    rc = png.decode(NULL, 0);


I realize pointing to a variable that then points to another variable. I believe this may be what pointers are for(but I also have no idea, am in way over my head here) but I've never used them before. Could someone guide me on how I could go about solving this so I can define which array I want to use in the function?

1 Comment
21:38 UTC


How to clear the Arduino IDE serial monitor on every loop?

Good day everyone,

I want to clear the serial monitor on every void loop cycle starts. I dont want to have to scroll down to see the latest data being printed.

How can I do it?

1 Comment
21:12 UTC


Can someone help me spot the error in my code? I'm working on a project on Tinkercad using 2 Arduinos, where I press a button on one and the other lights up a led, and vice versa. Both have the same code.

int buttonPin = 7;

int led = 8;

bool ledState = false;

String serialCommand = "null";

String on = "liga";

String off = "desliga";

void setup() {

pinMode(botaoPin, INPUT);

pinMode(led, OUTPUT);



void loop() {

if (Serial.available()){

serialCommand = Serial.readStringUntil('\n');

if (serialCommand == "off"){

digitalWrite(led, LOW);


if(serialCommand == "on"){

digitalWrite(led, HIGH);



if (digitalRead(buttonPin) == !LOW){

if (ledState == false){


ledState = true;


if (ledState == true){


ledState = false;







1 Comment
19:53 UTC


Methods to "program" a pre-built, on-the-market Drone with Arduino

I made a post (that i deleted) about my project of a Drone that at Point A goes to Point B when Point B makes a signal (tripwire i guess) and takes a Picture/Records Video (demonstration shouldn't be more than 10 meters away from where the drone is placed and where Point B is). I realized how much time and effort is needed if i try making the drone from scratch, and its parts are not available in my country, and being an archipelago it takes even longer to get them from the country capital. And the fact i have a month doesn't help, it was an abrupt decision from the teacher and department.

So after some thought, maybe i can use a pre-built drone and just "hijack" the drone using arduino things which will instead tell it to "go here and picture, then go back"

Is it possible? Is there an ACTUAL way to connect arduino to a pre-built drone? need halp

19:44 UTC


Arduino SpripTrap Helmet Project

Hey guys! I am starting a Spring Trap costume project and I got this wiring diagram on thingiverse where I am downloading the files, my question is do I have to have 3 different 9 volt battery’s, one to power the ardunino, one for one of the power circuit boards and one for the other power circuit board? Also is there a way to make it rechargeable, what do you guys think?

19:35 UTC


Waterproofing Breakout Boards which measure VOCs (Volatile Organic Gasses)

TL;DR: Looking for advice on waterproofing gas sensor breakout boards for sealed terrariums, hoping to find a conformal coating or waterproofing method that will minimize release of VOC (volatile organic compounds) into the sealed environments.

Hi friends,
I'm working on a sensor project for a biology club I run after school. I'm pretty excited about it but I'll give a quick summary and then get straight to the point for this question and make a proper detailed post later.

Short summary:
We are building a number of sealed terrariums in 1L mason jars making subtle changes to different starting parameters and will be observing them for the rest of the semester. I've decided to rope in some computer science students and together we are designing a system to collect data without opening the jars.
For atmospheric measurements I will be leaning heavily on the ENS160 + ATH2x dual sensor board. I suspect the organic materials won't allow us to have an accurate CO2 reading, but we'll test this as I have a couple of SDA40 breakout boards. Regardless, the TVOC measurement should provide some interesting results as to the amount of catabolism taking place in the soil.
DS18B20 soil probe
Gikfun Capacitive Soil Moisture V1.2

Question #1:
I am concerned about condensation shorting out sensor breakout boards, and so I started doing some reading on ways to waterproof circuit boards. Lots of options, seems simple enough, however I am particularly concerned about various conformal coatings continuing to off gas VOCs even after being fully cured. Not only would these be potentially toxic to the isopods and springtails in the terrariums, but they could potentially throw the VOC measurements off completely, negating the use of this sensor in the first place.
I'm planning to run a test of several types of conformal coatings and see how the affect the VOC sensor readings, but I was hoping for any advice in advance, or suggestions about what waterproofing approach might minimize VOCs.
-Rubber spray (given to me by the computer engineer teacher)
-MG chemicals 422C (silicone)
-MG chemicals 419E (acrylic)
-Aqueon Aquarium silicone (non-toxic)
-Let's Resin UV resin

Question #2:

Another possible solution is to enclose the sensor board in an enclosure with a water-tight but gas permeable membranes (PTFE - essentially Teflon).  These are readily available for use in growing mushrooms - keeping a container moist but allowing for O2 to diffuse in and CO2 to diffuse out.  I've sourced some for cheap and ordered them in for testing.  If I use this system, I will require an additional humidity sensor on the outside of that chamber to collect true humidity.  My greatest concern with this approach would is that filter membrane will prevent diffusion of some larger VOCs. Does anyone have any thoughts on this? I will also run some tests, but the more insights on this, the better.

Thanks in advance!

19:17 UTC


Some help with arduino iot mkr1010

Hello, to start off I want to apologize for being so godawfully stupid.

I have a project coming up for engineering. We (we as in my team and I) have been tasked to design a pneumatic form of the game chicken scream. We want to be able to start the game using a website or a link. We also want to be able to display the highscores there. So to start off I've tried to light up a led using the arduino iot cloud or whatever its called. And its not going great at all. Im not familiar with this at all. But I started off by connecting my mkr1010 wifi to the cloud which worked. I then wrote a little program ( see down here) and made the right circuit. I tried to upload to file but it has tons of errors. I feel like im doing a lot of things insanely wrong :) please help



/usr/local/bin/arduino-cli compile --fqbn arduino:samd:mkrwifi1010 --build-cache-path /tmp --output-dir /tmp/3999985337/build --build-path /tmp/arduino-build-3EF26A7DD58C2B45A0E4D16E7767D9F9 /tmp/3999985337/Untitled_apr19a

In file included from /home/builder/Arduino/libraries/arduino_connectionhandler_0_8_1/src/Arduino_ConnectionHandler.h:26:0,

from /home/builder/Arduino/libraries/arduinoiotcloud_1_15_1/src/ArduinoIoTCloud.h:27,

from /tmp/3999985337/Untitled_apr19a/thingProperties.h:3,

from /tmp/3999985337/Untitled_apr19a/Untitled_apr19a.ino:7:

/home/builder/Arduino/libraries/arduino_debugutils_1_4_0/src/Arduino_DebugUtils.h:32:1: error: expected initializer before 'static'

static int const DBG_NONE = -1;


Multiple libraries were found for "ECCX08.h"

Used: /home/builder/opt/libraries/arduinoeccx08_1_3_8

Not used: /home/builder/opt/libraries/rak5814_atecc608a_1_0_0

Multiple libraries were found for "WiFiNINA.h"

Used: /home/builder/opt/libraries/wifinina_1_8_14

Not used: /home/builder/opt/libraries/betterwifinina_1_3_0

Not used: /home/builder/opt/libraries/vega_wifinina_1_0_1

Multiple libraries were found for "Wire.h"

Used: /home/builder/.arduino15/packages/arduino/hardware/samd/1.8.13/libraries/Wire

Not used: /home/builder/opt/libraries/flexwire_1_2_0

Multiple libraries were found for "SPI.h"

Used: /home/builder/.arduino15/packages/arduino/hardware/samd/1.8.13/libraries/SPI

Not used: /home/builder/opt/libraries/eventethernet_1_0_0

Error during build: exit status 1

1 Comment
18:26 UTC


[Nano ESP32] Board repeatedly connects/disconnects through USB; can't load new firmware

Nano ESP32, Arduino IDE 2.3.2, Windows 10

Hi! I've been loading different programs onto the board the last few weeks, but yesterday I flashed a new program onto the board and suddenly it started repeatedly disconnecting and reconnecting every few seconds to my laptop. I can't even load a blank firmware onto the board to reset it because it won't stay connected long enough.

Here's what I've tried so far:

  1. Enter bootloader mode by double-tapping the RST button. When I do this, the COM port disappears from the Arduino IDE and Device Manager (Windows). Without the COM port, I can't upload new code. I've tried restarting the IDE, plugging, unplugging--no effect.
  2. Enter firmware download mode by shorting GND and B1 pins and simultaneously pressing the RST button. When I do this, the IDE no longer recognizes the board as a Nano ESP32 and now thinks it's a LOLIN S3 ("SN: (null)" in the Board Info screen) and changes the COM port (in the most recent case, from COM10 to COM9). When I try to upload the new code through this port, I get "No DFU capable USB device available; Failed uploading: uploading error: exit status 74".

Any ideas? It's a pain that a slight change in my code would cause such a haywire reaction.

15:58 UTC


COM5/firmware.bin no such file or directory

hi guys, recently i bought a portenta machine control and i tried uploading a simple code to print “hello world” on the serial monitor.

however i encountered an error ‘com5/firmware.bin no such file or directory’

i’m using VS Code with the PlatformIO IDE extension and i added this line of code in the platform.ini file ‘upload_protocol = mbed’ which resulted in the error above.

need some help on how to solve this issue. any help is appreciated, thanks in advance!

12:27 UTC


Guys what's the best website to convert a song into notes so i can play it on a buzzer?

I'm creating a project and I'd like it to play songs through a buzzer, but I'm unable to find a website that transforms that song into the required stuff for arduino.

14:17 UTC


A reliable method for detecting fakes - their quiescent current

I've been plagued with fake sensors and chips for a while - fake ADS1115's, fake DS18B20's, and sometimes the fakes go to extreme lengths to copy the chip markings and even on-board serial number ROMs.

And sometimes it's tough to know if you're getting reliable sensor readings or not - what use is the stated % accuracy in the datasheet if you don't know if it's a fake? And if you can't read an on-board serial number or inspect with a microscope, what else can you do?

In designing a low power circuit, I discovered about half of my sensors are drawing 10-100x more current in sleep than their datasheets claim they are supposed to. The ADS1115 for example, is supposed to draw 200uA when turned on and only 1.5uA when powered down, but the fake one never powers down. It functions the same, it just draws way more current.

This happens to be one of the fake ADS1115's that only ever output a 12-bit signal even though they are claiming to be 16-bit. Swapping it out for a genuine module sees the current drop considerably.

This is how I will be testing for fakes from now on - connect them to a circuit and measure their current draw in their supposed "low power state" or "sleep mode" and then compare it to their datasheet - fakes won't even be in the same ballpark.

14:12 UTC


Which LLM is great for Arduino projects?

Im very new to arduino and im new with C++,

I’ve done C# before and Python but I can’t do projects with those on arduino it appears idk.

Iv been using ChatGPT 4 for trying to create a project I want. And I need it to guide me on parts and connects on what to do and I need it for the coding part also. But it has been veeeery hit or miss with the code and the non coding stuff.

Is there a different A.I llm that is really good at those things, heard of Claude Opus 3 but it’s like a mix people love it and people say it’s similar to gpt4 level.

Any suggestions? Even open source ones?

13:19 UTC


pid control help for lfr

i m trying to make pid based lfr , but my motors are not working properly . the output screen shows change in speed however there is no change in actual motor speed , hardware

5 ir sensors

l298d motor driver

2 dc bo motors

arduino uno

7.4 power supply

float Kp = 0.1; // Proportional gain
float Ki = 0.01; // Integral gain
float Kd = 0.05; // Derivative gain
float error = 0, P = 0, I = 0, D = 0, PID_value = 0;
float previous_error = 0, previous_I = 0;
int sensor[5] = {0, 0, 0, 0, 0};
int initial_motor_speed = 150; // 
int left_motor_speed = 0; // 
int right_motor_speed = 0; // 

void read_sensor_values();
void calculate_pid();
void motor_control();

void setup() {
  pinMode(A0, INPUT);
  pinMode(A1, INPUT);
  pinMode(A2, INPUT);
  pinMode(A3, INPUT);
  pinMode(A4, INPUT);
  pinMode(10, OUTPUT); // PWM Pin 1
  pinMode(5, OUTPUT); // PWM Pin 2
  pinMode(9, OUTPUT); // Left Motor Pin 1
  pinMode(8, OUTPUT); // Left Motor Pin 2
  pinMode(7, OUTPUT); // Right Motor Pin 1
  pinMode(6, OUTPUT); // Right Motor Pin 2
  Serial.begin(9600); // 

void loop() {

  //Print sensor values, error, PID output, and motor speeds
  Serial.print("Sensor values: ");
  for (int i = 0; i < 5; i++) {
    Serial.print(" ");
  Serial.print("Error: ");
  Serial.print(", PID output: ");
  Serial.print(", Left motor speed: ");
  Serial.print(", Right motor speed: ");

  delay(100); // 

void read_sensor_values() {
  sensor[0] = digitalRead(A0);
  sensor[1] = digitalRead(A1);
  sensor[2] = digitalRead(A2);
  sensor[3] = digitalRead(A3);
  sensor[4] = digitalRead(A4);

void calculate_pid() {
  error = sensor[0] * 4 + sensor[1] * 3 + sensor[2] * 2 + sensor[3] - sensor[4] * 2;
  P = error;
  I = I + error;
  D = error - previous_error;
  PID_value = Kp * P + Ki * I + Kd * D;
  previous_error = error;

void motor_control() {
  left_motor_speed = initial_motor_speed - PID_value;
  right_motor_speed = initial_motor_speed + PID_value;

  left_motor_speed -= 50; // Decrease left motor speed
  right_motor_speed += 50; // Increase right motor speed

  left_motor_speed = constrain(left_motor_speed, 0, 255); // 
  right_motor_speed = constrain(right_motor_speed, 0, 255);

  analogWrite(10, left_motor_speed); // Left Motor Speed
  analogWrite(5, right_motor_speed); // Right Motor Speed

  // Motor direction control to move forward
  digitalWrite(9, HIGH);
  digitalWrite(8, LOW);
  digitalWrite(7, LOW);
  digitalWrite(6, HIGH);

the code.

for connection i have double checked them

Arduino is powered by the 7.4 v battery through vin from motor driver , i m thinking it has something to do with power supply of pwn pin or something with my code , any help or advice is appreciated


13:13 UTC


Font sizes Adafruit GFX library

Is there a resource that gives the actual font sizes for the setTextSize? The best I can find is that size 2 is 10x16 px per character. I'm trying to layout some data on my screen in a specific way and knowing how much space the characters take will make it so much easier, rather than constantly trying to guess

13:12 UTC


How do i fix this? I need help pls

Everytime i try to upload it to my arduino Nano this is what i get. woud be nice if someone can help

11:38 UTC


Guidance on long range wireless data cast and/or video feed

Looking to make a project rocket and (potentially) an AI FPV drone with multiple sensors. I have an Arduino clone with multiple components, and a WEMOS r1 and d1 mini. *Im not making a combat drone, they're 2 separate projects.*

Essentially, need a way to receive communications long distance (rocket up to 2000- 2500ft) and drone maybe 1-2km.


- Flight metrics
- Altitude
- Speed
- Anything else id need to log live in case rocket gets lost during flight or blows up

- Long range control
- Video cast
- Etc Etc

Looking for cheapest solution or mid tier price solution. Just lmk what parts/modules I would need to at least get long range comms/video cast. If a RBP is the better solution, lmk.

11:23 UTC


Multiple channels MIDI input to VCV Racks (music software) from Arduino through Control_Surface library


I'm trying to transform a super simple analog input from a light sensor into a multiple channel MIDI input to feed into VCV Racks. I already managed to obtain a 1 channel version with an example code.

What I'm trying to do now is to split the signal from the same sensor in 5 different channels with different delays, in order to make them update at different speeds and for this obtain a multichannel inputs that incorporates different moments of the same changing signal.

The problem with all my tryouts is that when I feed it into VCV Racks and I connect the MIDItoCV input to a VIZ module, it shows only one channel active.

I don't understand if the problem could be the code, the cable (I'm using a USB-A-USB-B to connect the Arduino with the laptop) or the module I'm using in VCV Racks.

If someone is familiar with the topic and could help me would be amazin ;;)

VCV rack module

Light sensor setup

 * This example demonstrates the use of MIDI Pitch Bend potentiometers that
 * can be used for changing effect parameters, volumes, pan and balance
 * controls, etc. It can control almost any knob in your DAW software.
 * @boards  AVR, AVR USB, Nano Every, Due, Nano 33 IoT, Nano 33 BLE, UNO R4, Pi Pico, Teensy 3.x, ESP32, ESP8266
 * Connections
 * -----------
 * - A0: wiper of a potentiometer
 * Connect the left terminal of the potentiometer to ground, and the right one
 * to V<sub>CC</sub>.
 * Behavior
 * --------
 * - When you turn the potentiometer, you should receive MIDI Pitch Bend
 *   events on channel 1, with a value between -8192 and +8191.
 * - The analog input is filtered, so there shouldn't be any noise on the 
 *   position. If there is, check your wiring, and make sure that the resistance
 *   of the potentiometer isn't too high (10 kΩ is ideal).
 * Mapping
 * -------
 * Select the Arduino as a custom MIDI controller in your DAW, and use the 
 * MIDI learn option to assign the potentiometer to a function.
 * Written by PieterP, 2019-08-23  
 * https://github.com/tttapa/Control-Surface

#include <Control_Surface.h> // Include the Control Surface library

// Instantiate a MIDI over USB interface.
USBMIDI_Interface midi;

// Instantiate a PBPotentiometer object
PBPotentiometer potentiometer {
  A0,        // Analog pin connected to potentiometer
  Channel_1, // MIDI Channel 1

void setup() {
  Control_Surface.begin(); // Initialize Control Surface

void loop() {
  Control_Surface.loop(); // Update the Control Surface
09:54 UTC


Can you use the Vin pin on the leonardo as a 9V supply if you use the batteries? Or am i gonne break something?

09:14 UTC


DIY EV Charging Station with Arduino Uno

Hey Arduino fans! I made an EV charging station based on an Arduino Uno. Would you like to check it out?

09:07 UTC


Arduino UNO R4 WiFi connecting to the Adafruit Dashboard

Trying to get an Arduino to connect the Adafruit dash board.

It would probably be better to use the Arduino dashboard but the requirements of the project want us to use the Adafruit one.

Connecting the Arduino to WiFi using AdafruitIO_WiFi.h and WiFiNINA.h isn’t working as the Arduino doesn’t utilize SPI to connect to its WiFi chip.

When I tried to use just the AdafruitIO.h library and then WiFi3.h for the connection to WiFi I was able to get the WiFi to connect but whenever I added the Adafruit portion the compiler would throw an error about not being able to use the AdafruitIO.h library by itself.

Any advice is welcome.

TL:DR: using an arduino R4 WiFi with the Adafruit dash board how?

09:05 UTC


Switched from I2C LCD to SPI OLED, do I have to use do/while?

I'm trying to update my code that was almost debugged, but with an I2C LCD to work with an SPI OLED instead. This is my first time using SPI (and I2C...and Arduino). I've managed to get the library figured out and the OLED working on a basic sketch. I've even started to integrate it into my code, but the example sketch I followed to get it working uses a do/while statement and when I integrate it that way into my project it appears to slow things down considerably. Where I used to be able to rotate an encoder knob by hand and see the numbers on the LCD update maybe 10 or more times per second, now I'm only able to get roughly one update per second. It's a long, messy sketch right now but long story short, I have to write it with a do/while function, something like this to get it to work

#include <Arduino.h>
#include <U8g2lib.h>
#include <SPI.h>
#include <Wire.h>

U8G2_SH1122_256X64_2_4W_SW_SPI u8g2(U8G2_R2, 13, 12, 10, 3); 

void setup(void) { 

void loop(void) {   
  do { u8g2.setFont(u8g2_font_VCR_OSD_tu); 
  u8g2.drawStr(0,15,"HELLO WORLD!");
  } while ( u8g2.nextPage() );

but I would much rather write to the display like this, since it better matches my existing code that I already know works

#include <Arduino.h>
#include <U8g2lib.h>
#include <SPI.h>
#include <Wire.h>

U8G2_SH1122_256X64_2_4W_SW_SPI u8g2(U8G2_R2, 13, 12, 10, 3);  

void setup(void) { 

void loop(void) {   
u8g2.print("HELLO WORLD!");

I can't get this second method to work. Hopefully something simple with my setup. Any ideas what I'm doing wrong?

07:15 UTC


Doubt about capacitors

Today I stripped a charger to power my Arduino projects without the need for batteries. I've also read that it's a good practice to solder a capacitor to the corresponding terminals of the cables (typically, red cable positive, black cable negative) to protect the circuit from sudden voltage spikes.

Now, as far as I understand, in DC a capacitor charges and acts as an open circuit, so no current should flow through it. Before soldering, I tried to turn on an LED using the stripped cable of the charger and placing a capacitor before the LED and its resistor, and the current evidently followed the flow. I even removed the stripped ends of the cable and could see the LED gradually dimming, so the capacitor works perfectly.

I know I'm missing something about how capacitors work, but I don't know what it is. Thank you very much.

07:13 UTC


[New to arduino/electronics] Are these LEDs in series with each other?


Are these two LEDs in series with each other? I think that since both of them are in the positive power rail they share that node but I'm unsure about the grounds since I have two unique connection points for them.

06:49 UTC


Please suggest a cutoff and protect the circuit/module for TP4056

Hi, I am new to electronics. I am creating a solar-based charging system that is based on TP4056(for esp32). My solar panel produces 9-volt max. anyone please suggest a minimum and maximum voltage cutoff and protect the system for TP4056? Or anyone can provide a cheap charging module with a 5-volt out that can be used safely with a 9v max solar panel.


06:13 UTC


Having to disconnect and reconnect Arduino every time I connect to it in Unreal.

I am currently working on a project in Unreal where I need to read the data on the Arduino from a rfid scanner using the Serial COM plugin. The first time I play the game it will connect fine but if I play again it won't be detected unless I disconnect and reconnect the Arduino.

Is there something I'm doing wrong like needing to reset the Arduino after a playthrough? The port does get closed when the game ends so I'm not too sure why this is happening.

For this project I'm using the Arduino Uno and Unreal 5.32.

If anyone has any idea what could be causing this I'd really appreciate it!

Edit: This also happens in Serial Port Monitor, I can connect once then if I close it and open the port again It says 'The selected port is being used by another software' and it fails to connect.

04:53 UTC


Is circuit.io down for anyone else?

https://www.circuito.io Sorry if this isn’t the right subreddit for this, but I’m working on a project with an arduino and I really wanted to use circuit.io but it doesn’t seem to be working for me?? 😔 my project is time sensitive and I like circuit io because it wires everything for you automatically

03:27 UTC


Which sensor is cappable of detecting soap-bubbles (for a bubble-meter)?

23:55 UTC


Is this a short circuit??

I’m doing this competition and I need my robot to move faster. I was setting up my code to run the dc motor at full speed but one of my team mates who developed their own robot has theirs going faster. I knew it wasn’t the code I made so I checked the chassis made by the previous year’s competitors and found a 103 capacitor jumping the positive and negative terminals. I was wondering if this was causing a short circuit and if it was hindering my robots speed and power.

23:46 UTC

Back To Top