r/ArduinoHelp • • Aug 01 '25

DFPlayer Mini refuses to initialise properly

Thumbnail reddit.com
2 Upvotes

r/ArduinoHelp • • Jul 25 '25

Need help with ESP32 Cam

2 Upvotes

when compiling the code in arduino IDE, it says unable to execute file at sketch location

it's an emergency, someone please help fix


r/ArduinoHelp • • Jun 22 '25

What is the difference between this projects?

Thumbnail
gallery
2 Upvotes

Why the first one is working and the second is not working if they are the same?

This is the code:

int seconds = 0;

LiquidCrystal lcd_1(12, 11, 5, 4, 3, 2);

void setup()

{

lcd_1.begin(16, 2); // Set up the number of columns and rows on the LCD.

// Print a message to the LCD.

lcd_1.print("hello world!");

}

void loop()

{

// set the cursor to column 0, line 1

// (note: line 1 is the second row, since counting

// begins with 0):

lcd_1.setCursor(0, 1);

// print the number of seconds since reset:

lcd_1.print(seconds);

delay(1000); // Wait for 1000 millisecond(s)

seconds += 5;

}


r/ArduinoHelp • • Jun 08 '25

Checking my arduino circuit, will it work?

Post image
2 Upvotes

updated from a design, can you see problem with this?


r/ArduinoHelp • • Jun 07 '25

My ESC/motor wont be controlled despite having power

Post image
2 Upvotes

Motor doesnt turn. motor beeps when powered. Im just trying to get it to spin at all and nothings happening. it will be apart of a drone and will have others connected similarly but not even this one works. Both esc and motor were purchased on amazon and do not provide datasheets. The ESC's brand is aneegfpv, it is a 40a max ESC with 2-6s input which is in range of our lipo. The motor is CENPEK A2212 1000KV Brushless Motor 13T. multiple variations of code has been tried.

Codes:

/*ESC calibration sketch; author: ELECTRONOOBS */ 
#include <Servo.h> 
#define MAX_SIGNAL 2000 
#define MIN_SIGNAL 1000 
#define MOTOR_PIN 9 
int DELAY = 1000; 
Servo motor; 

void setup() { 
  Serial.begin(9600); 
  delay(1500);
  Serial.println("Program begin...");
  delay(1000);
  motor.attach(MOTOR_PIN);
  motor.writeMicroseconds(MAX_SIGNAL); // Wait for input 
  motor.writeMicroseconds(MIN_SIGNAL);
} 
  
  
  void loop() {
  if (Serial.available() > 0) { 
    int DELAY = Serial.parseInt();
    if (DELAY > 999) {
      motor.writeMicroseconds(DELAY); 
      float SPEED = (DELAY-1000)/10; 
      Serial.print("\n"); 
      Serial.println("Motor speed:"); 
      Serial.print(" "); 
      Serial.print(SPEED);
  Serial.print("%"); } } }





/*ESC calibration sketch; author: ELECTRONOOBS */ 
#include <Servo.h> 
#define MAX_SIGNAL 2000 
#define MIN_SIGNAL 1000 
#define MOTOR_PIN 9 
int DELAY = 1000; 
Servo motor; 


void setup() { 
  Serial.begin(9600); 
  delay(1500);
  Serial.println("Program begin...");
  delay(1000);
  motor.attach(MOTOR_PIN);
  motor.writeMicroseconds(MAX_SIGNAL); // Wait for input 
  motor.writeMicroseconds(MIN_SIGNAL);
} 
  
  
  void loop() {
  if (Serial.available() > 0) { 
    int DELAY = Serial.parseInt();
    if (DELAY > 999) {
      motor.writeMicroseconds(DELAY); 
      float SPEED = (DELAY-1000)/10; 
      Serial.print("\n"); 
      Serial.println("Motor speed:"); 
      Serial.print(" "); 
      Serial.print(SPEED);
  Serial.print("%"); } } }

#include <Servo.h>
Servo esc;
void setup() {
  // put your setup code here, to run once:
  esc.attach(10);
  esc.write(180);
  delay(2000);
  esc.write(0);
  delay(2000);
  esc.write(20);
  delay(2000);
  esc.write(0);
  delay(2000);
}

void loop() {
  // put your main code here, to run repeatedly:
  esc.write(1000);
  delay(5000);
  esc.write(0);

}
#include <Servo.h>
Servo esc;
void setup() {
  // put your setup code here, to run once:
  esc.attach(10);
  esc.write(180);
  delay(2000);
  esc.write(0);
  delay(2000);
  esc.write(20);
  delay(2000);
  esc.write(0);
  delay(2000);
}


void loop() {
  // put your main code here, to run repeatedly:
  esc.write(1000);
  delay(5000);
  esc.write(0);


}

r/ArduinoHelp • • Jun 05 '25

Help with arduino code for exam

2 Upvotes

Hey guys!
Me and a few friends are working on a group project for an exam, and one of the requirements is that we have to use Arduino for it to be approved. We've been struggling with it for a couple of days now, and we were hoping the people of Reddit could help us out.

We want to use either one Arduino board + two breadboards, or two Arduino boards + two breadboards. The idea is that they should be connected and able to communicate with each other.

Here’s the goal of the code:
We’ll have two identical prototypes, let’s call them P1 and P2. Each one has its own light and its own button. When the button on P1 is pressed, the light on P2 should turn on. That light should stay on until the button on P2 is pressed — but pressing that button won’t send a light back, so we avoid an endless loop. After that, everything resets, and either button can be pressed again to send a new light.

If you're curious about the idea behind the project, here’s the background:
We’ve been interviewing some elderly people to try to find unmet needs, and this is what we came up with based on their input. The prototypes will be shaped like flowerpots, and the idea is that the users can press a button to send a small light signal to family or friends — just as a way to say “I’m thinking of you.” It’s meant to be a super simple form of communication that can help families stay connected, especially when they have busy schedules and aren’t able to visit as often as they’d like.

We’d really appreciate any help or advice, especially from anyone with experience with Arduino.

And if anyone’s interested, we’d be happy to share updates or photos of the finished product once it’s done!

Thanks in advance


r/ArduinoHelp • • Jun 02 '25

Help

2 Upvotes

When i conect an control module to my arduino it only registers voltage for a few secons and then... nothing! Does anyone know what this could be due to?


r/ArduinoHelp • • May 30 '25

Can't figure out how to rotate these numbers on my MAX7219 display

Post image
2 Upvotes

I've combined a few pieces of arduino code I found online to create a weather station which just shows the current static weather. The code works fine but the display is showing the numbers rotated 90 degrees anti-clockwise in each of these 8x8 segments. I think the problem is the section where int x and int y are defined but I dont really know! I have already tried setRotation(1) and it only shows one clipped number. The code is below, thank you in advance!

#include <Arduino.h>
#if defined(ESP8266)
#include <ESP8266WiFi.h>
#else
#include <WiFi.h>
#endif
#include <JsonListener.h>
#include <time.h>
#include "OpenWeatherMapCurrent.h"
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Max72xxPanel.h>
#include <time.h>

int pinCS = D8; 
int numberOfHorizontalDisplays = 4;
int numberOfVerticalDisplays   = 1;

String message;

// initiate the client
OpenWeatherMapCurrent client;
OpenWeatherMapCurrentData data;  // GLOBAL data variable

// Your OpenWeatherMap API key
String OPEN_WEATHER_MAP_APP_ID = "XXXX";

// Location settings
float OPEN_WEATHER_MAP_LOCATION_LAT = XXXX;
float OPEN_WEATHER_MAP_LOCATION_LON = XXXX;
String OPEN_WEATHER_MAP_LANGUAGE = "en";
boolean IS_METRIC = true;

// WiFi settings
#if defined(ESP8266)
const char* ESP_HOST_NAME = "esp-" + ESP.getFlashChipId();
#else
const char* ESP_HOST_NAME = "esp-" + ESP.getEfuseMac();
#endif
const char* WIFI_SSID     = "XXXX";
const char* WIFI_PASSWORD = "XXXX";

// initiate the WifiClient
WiFiClient wifiClient;

// MAX7219 display object
Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays);

void connectWifi() {
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  Serial.print("Connecting to ");
  Serial.println(WIFI_SSID);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected!");
  Serial.println(WiFi.localIP());
  Serial.println();
}

void fetchAndPrintWeather() {
  client.setLanguage(OPEN_WEATHER_MAP_LANGUAGE);
  client.setMetric(IS_METRIC);
  
  client.updateCurrent(&data, OPEN_WEATHER_MAP_APP_ID, OPEN_WEATHER_MAP_LOCATION_LAT, OPEN_WEATHER_MAP_LOCATION_LON);

  Serial.println("------------------------------------");
  Serial.printf("Temp: %f\n", data.temp);
  Serial.println("---------------------------------------------------/\n");
}

void display_message(String message) {
  matrix.fillScreen(LOW);
  int x = 2;
  int y = (matrix.height() - 8) / 2;

  for (int i = 0; i < message.length(); i++) {
    matrix.drawChar(x, y, message[i], HIGH, LOW, 1);
    x += 6;
    if (x > matrix.width() - 6) break;
  }
  matrix.write();
}

unsigned long lastUpdate = 0;
const unsigned long interval = 10000; // 

void setup() {
  Serial.begin(115200);
  delay(500);
  connectWifi();

  matrix.setIntensity(5);
  matrix.setRotation(0);
  matrix.fillScreen(LOW);
  matrix.write();
}

void loop() {
  unsigned long currentMillis = millis();
  if (currentMillis - lastUpdate >= interval) {
    lastUpdate = currentMillis;
    fetchAndPrintWeather();

    message = String(data.temp, 1) + "C";
    display_message(message);
  }
}

r/ArduinoHelp • • May 07 '25

Help, the button is not doing it's work when being pressed, also can you give some advice to make the sensor more accurate

Thumbnail
gallery
2 Upvotes

here is our code

include "ssd1306h.h"

include "MAX30102.h"

include "Pulse.h"

include <avr/pgmspace.h>

include <EEPROM.h>

include <avr/sleep.h>

ifndef cbi

define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))

endif

ifndef sbi

define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))

endif

SSD1306 oled; MAX30102 sensor; Pulse pulseIR; Pulse pulseRed; MAFilter bpm;

define LED LED_BUILTIN

define BUTTON 3

define OPTIONS 7

static const uint8_t heart_bits[] PROGMEM = { 0x00, 0x00, 0x38, 0x38, 0x7c, 0x7c, 0xfe, 0xfe, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0xf8, 0x3f, 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

//spo2_table is approximated as -45.060ratioAverage ratioAverage + 30.354 *ratioAverage + 94.845 ; const uint8_t spo2_table[184] PROGMEM = { 95, 95, 95, 96, 96, 96, 97, 97, 97, 97, 97, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 96, 95, 95, 95, 94, 94, 94, 93, 93, 93, 92, 92, 92, 91, 91, 90, 90, 89, 89, 89, 88, 88, 87, 87, 86, 86, 85, 85, 84, 84, 83, 82, 82, 81, 81, 80, 80, 79, 78, 78, 77, 76, 76, 75, 74, 74, 73, 72, 72, 71, 70, 69, 69, 68, 67, 66, 66, 65, 64, 63, 62, 62, 61, 60, 59, 58, 57, 56, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 31, 30, 29, 28, 27, 26, 25, 23, 22, 21, 20, 19, 17, 16, 15, 14, 12, 11, 10, 9, 7, 6, 5, 3, 2, 1 } ;

int getVCC() { //reads internal 1V1 reference against VCC

if defined(AVR_ATmega1284P)

ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);  // For ATmega1284

else

ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);  // For ATmega328

endif

delay(2); // Wait for Vref to settle ADCSRA |= _BV(ADSC); // Convert while (bit_is_set(ADCSRA, ADSC)); uint8_t low = ADCL; unsigned int val = (ADCH << 8) | low; //discard previous result ADCSRA |= _BV(ADSC); // Convert while (bit_is_set(ADCSRA, ADSC)); low = ADCL; val = (ADCH << 8) | low;

return (((long)1024 * 1100) / val)/100;
}

void print_digit(int x, int y, long val, char c=' ', uint8_t field = 3,const int BIG = 2) {
uint8_t ff = field; do { char ch = (val!=0) ? val%10+'0': c; oled.drawChar( x+BIG*(ff-1)*6, y, ch, BIG); val = val/10; --ff; } while (ff>0); }

/*

  • Record, scale and display PPG Wavefoem */ const uint8_t MAXWAVE = 72;

class Waveform { public: Waveform(void) {wavep = 0;}

  void record(int waveval) {
    waveval = waveval/8;         // scale to fit in byte  缩放以适合字节
    waveval += 128;              //shift so entired waveform is +ve  
    waveval = waveval<0? 0 : waveval;
    waveform[wavep] = (uint8_t) (waveval>255)?255:waveval; 
    wavep = (wavep+1) % MAXWAVE;
  }

  void scale() {
    uint8_t maxw = 0;
    uint8_t minw = 255;
    for (int i=0; i<MAXWAVE; i++) { 
      maxw = waveform[i]>maxw?waveform[i]:maxw;
      minw = waveform[i]<minw?waveform[i]:minw;
    }
    uint8_t scale8 = (maxw-minw)/4 + 1;  //scale * 8 to preserve precision
    uint8_t index = wavep;
    for (int i=0; i<MAXWAVE; i++) {
      disp_wave[i] = 31-((uint16_t)(waveform[index]-minw)*8)/scale8;
      index = (index + 1) % MAXWAVE;
    }
  }

void draw(uint8_t X) { for (int i=0; i<MAXWAVE; i++) { uint8_t y = disp_wave[i]; oled.drawPixel(X+i, y); if (i<MAXWAVE-1) { uint8_t nexty = disp_wave[i+1]; if (nexty>y) { for (uint8_t iy = y+1; iy<nexty; ++iy)
oled.drawPixel(X+i, iy); } else if (nexty<y) { for (uint8_t iy = nexty+1; iy<y; ++iy)
oled.drawPixel(X+i, iy); } } } }

private: uint8_t waveform[MAXWAVE]; uint8_t disp_wave[MAXWAVE]; uint8_t wavep = 0;

} wave;

int beatAvg; int SPO2, SPO2f; int voltage; bool filter_for_graph = false; bool draw_Red = false; uint8_t pcflag =0; uint8_t istate = 0; uint8_t sleep_counter = 0;

void button(void){ pcflag = 1; }

void checkbutton(){ if (pcflag && !digitalRead(BUTTON)) { istate = (istate +1) % 4; filter_for_graph = istate & 0x01; draw_Red = istate & 0x02; EEPROM.write(OPTIONS, filter_for_graph); EEPROM.write(OPTIONS+1, draw_Red); } pcflag = 0; }

void Display_5(){ if(pcflag && !digitalRead(BUTTON)){ draw_oled(5); delay(1100); } pcflag = 0;

}

void go_sleep() { oled.fill(0); oled.off(); delay(10); sensor.off(); delay(10); cbi(ADCSRA, ADEN); // disable adc delay(10);


r/ArduinoHelp • • May 02 '25

Advice needed: automating a toy crane for phone control (ESP32 Project)

Post image
2 Upvotes

Hi all,

I'm diving into a project to automate a wooden toy crane so I can control its rotation, hoist (up/down), via a web interface on my phone. I'm planning to use an ESP32 or ESP8266 for the Wi-Fi and control logic.

I'm fairly comfortable with the ESP programming side but could use some community wisdom on the hardware implementation, specifically:

Best way to physically attach servos/motors to the crane for rotation and hoist control without major surgery? Looking for practical mounting techniques for these wooden toys.

Servo vs. small DC motor for the hoist? What works better for a simple winch-like action?

Component recommendations: Any favorite small servos, geared motors, motor drivers, or electromagnets suitable for this kind of small-scale automation?

Powering it all: Tips for cleanly powering the microcontroller, servos, and magnet, likely from a 5V source?

Thanks!


r/ArduinoHelp • • Apr 24 '25

Hi I'm confused on how to connect a Bluetooth module

2 Upvotes

Hi, as I said in the title, I'm a bit confused on what pins on my Arduino uno to connect the Bluetooth module to


r/ArduinoHelp • • Apr 20 '25

Why doesn't It work?(Novice)

Thumbnail
gallery
2 Upvotes

r/ArduinoHelp • • Apr 20 '25

Non coding guy trying to fix something, could you help me please?

2 Upvotes

So my coding ability is very limited, im just trying to fix a logitech shifter, long story short this "toy" sends button preses acording to the x and y axis locations for gear 1 to 6 and it has a switch for reverse, one of the potenciometers broke and there are not replacements, the logitech software will not recognize it but i changed the broken pot for another that will fit, but the traver is much larger compared to the oem pot so in the controller settings the y axis only moves a little and it will not reach full travel to engage the gear selected.

there is a sketch that everyone uses to convert the shifter to usb with an arduino, but since the y axis has changed it will not work with the new pot.

/*
 *  Project     Sim Racing Library for Arduino
 *  @author     David Madison
 *  @link       github.com/dmadison/Sim-Racing-Arduino
 *  @license    LGPLv3 - Copyright (c) 2022 David Madison
 *
 *  This file is part of the Sim Racing Library for Arduino.
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

 /**
 * @details Emulates the Logitech Driving Force shifter (included with
 *          the G923 / G920 / G29 wheels) as a joystick over USB.
 * @example LogitechShifter_Joystick.ino
 */

// This example requires the Arduino Joystick Library
// Download Here: https://github.com/MHeironimus/ArduinoJoystickLibrary

#include <SimRacing.h>
#include <Joystick.h>

// Set this option to 'true' to send the shifter's X/Y position
// as a joystick. This is not needed for most games.
const bool SendAnalogAxis = true;

// Set this option to 'true' to send the raw state of the reverse
// trigger as its own button. This is not needed for any racing
// games, but can be useful for custom controller purposes.
const bool SendReverseRaw = False;

//  Power (VCC): DE-9 pin 9
// Ground (GND): DE-9 pin 6
// Note: DE-9 pin 3 (CS) needs to be pulled-up to VCC!
const int Pin_ShifterX   = A0;  // DE-9 pin 4
const int Pin_ShifterY   = A2;  // DE-9 pin 8
const int Pin_ShifterRev = 2;   // DE-9 pin 2

// This pin requires an extra resistor! If you have made the proper
// connections, change the pin number to the one you're using
const int Pin_ShifterDetect = SimRacing::UnusedPin;  // DE-9 pin 7, requires pull-down resistor

SimRacing::LogitechShifter shifter(
  Pin_ShifterX, Pin_ShifterY,
  Pin_ShifterRev,
  Pin_ShifterDetect
);
//SimRacing::LogitechShifter shifter = SimRacing::CreateShieldObject<SimRacing::LogitechShifter, 2>();

const int Gears[] = { 1, 2, 3, 4, 5, 6, -1 };
const int NumGears = sizeof(Gears) / sizeof(Gears[0]);

const int ADC_Max = 1023;  // 10-bit on AVR

Joystick_ Joystick(
  JOYSTICK_DEFAULT_REPORT_ID,      // default report (no additional pages)
  JOYSTICK_TYPE_JOYSTICK,          // so that this shows up in Windows joystick manager
  NumGears + SendReverseRaw,       // number of buttons (7 gears: reverse and 1-6)
  0,                               // number of hat switches (none)
  SendAnalogAxis, SendAnalogAxis,  // include X and Y axes for analog output, if set above
  false, false, false, false, false, false, false, false, false);  // no other axes

void updateJoystick();  // forward-declared function for non-Arduino environments


void setup() {
  shifter.begin();

  // if you have one, your calibration line should go here
  
  Joystick.begin(false);  // 'false' to disable auto-send
  Joystick.setXAxisRange(0, ADC_Max);
  Joystick.setYAxisRange(ADC_Max, 0);  // invert axis so 'up' is up

  updateJoystick();  // send initial state
}

void loop() {
  shifter.update();

  if (SendAnalogAxis == true || shifter.gearChanged()) {
    updateJoystick();
  }
}

void updateJoystick() {
  // set the buttons corresponding to the gears
  for (int i = 0; i < NumGears; i++) {
    if (shifter.getGear() == Gears[i]) {
      Joystick.pressButton(i);
    }
    else {
      Joystick.releaseButton(i);
    }
  }

  // set the analog axes (if the option is set)
  if (SendAnalogAxis == true) {
    int x = shifter.getPosition(SimRacing::X, 0, ADC_Max);
    int y = shifter.getPosition(SimRacing::Y, 0, ADC_Max);
    Joystick.setXAxis(x);
    Joystick.setYAxis(y);
  }

  // set the reverse button (if the option is set)
  if (SendReverseRaw == true) {
    bool reverseState = shifter.getReverseButton();
    Joystick.setButton(NumGears, reverseState);  // "NumGears" is the 0-indexed max gear + 1
  }

  Joystick.sendState();

i already tried using the windows controller calibration and nothing, then i changed the range of the y axis from 0 to ADC_MAX, to something that in theory should work like 400 to 600 at lines "Joystick.setYAxisRange" and "int y = shifter.getPosition" and the control calibration says it moves to the edges, but it wont "engage the gear" and if i put the old broken pot it engaged the gear but its unstable because the pot track is probably damaged

If anyone can help me thanks in advance


r/ArduinoHelp • • Apr 16 '25

is there any thing i should improve on this

Post image
2 Upvotes

// C++ code

//

int i = 0;

int unnamed = 0;

int j = 0;

int counter;

void setup()

{

pinMode(1, OUTPUT);

pinMode(2, OUTPUT);

pinMode(3, OUTPUT);

pinMode(4, OUTPUT);

pinMode(5, OUTPUT);

pinMode(6, OUTPUT);

pinMode(7, OUTPUT);

pinMode(8, OUTPUT);

pinMode(9, OUTPUT);

pinMode(10, OUTPUT);

for (counter = 0; counter < random(10, 15 + 1); ++counter) {

digitalWrite(1, HIGH);

delay(100); // Wait for 100 millisecond(s)

digitalWrite(1, LOW);

digitalWrite(2, HIGH);

delay(100); // Wait for 100 millisecond(s)

digitalWrite(2, LOW);

digitalWrite(3, HIGH);

delay(100); // Wait for 100 millisecond(s)

digitalWrite(3, LOW);

digitalWrite(4, HIGH);

delay(100); // Wait for 100 millisecond(s)

digitalWrite(4, LOW);

digitalWrite(5, HIGH);

delay(100); // Wait for 100 millisecond(s)

digitalWrite(5, LOW);

digitalWrite(6, HIGH);

delay(100); // Wait for 100 millisecond(s)

digitalWrite(6, LOW);

digitalWrite(7, HIGH);

delay(100); // Wait for 100 millisecond(s)

digitalWrite(7, LOW);

digitalWrite(8, HIGH);

delay(100); // Wait for 100 millisecond(s)

digitalWrite(8, LOW);

digitalWrite(9, HIGH);

delay(100); // Wait for 100 millisecond(s)

digitalWrite(9, LOW);

digitalWrite(10, HIGH);

delay(100); // Wait for 100 millisecond(s)

digitalWrite(10, LOW);

}

}

void loop()

{

i += random(1, 10 + 1);

delay(10); // Delay a little bit to improve simulation performance

}


r/ArduinoHelp • • Apr 06 '25

trying to fit too much

2 Upvotes

I'm making a midi controller and i want to have 5 groups of 1 rgb led, 1 pot and 1 switch. However I'm having trouble working out how i should wire it since currently each group uses 4 digital pins and 1 analogue which seems like more than it needs to be.

I've seem some stuff about multiplexing but I'm really not sure.


r/ArduinoHelp • • Apr 05 '25

Need help identifying what I'm missing for this LED project I'm working on.

Thumbnail
gallery
2 Upvotes

I've been trying to write a sketch that can control this LED strip, but I can't figure out what it needs. I've tried looking up lots of sources online and have found nothing of help. I know this is not an individually addressable led strip, but I would still like to use it if possible. My goal is to use this strip in a larger project, using it to change colours and brightness depending on some other variables. For now I'd like to learn how to control just the colours and brightness. The rest I can figure out on my own. I have added some wires to draw power from the USB cable to power the arduino when the project is complete (yes I know I don't have the wire there). The little PCB board had an IR sensor where the blue wire was that took a signal from a remote to change colour and use functions. Underneath the blue wire it reads "CER-RGB-003". The only other markings I have found are written on the strip itself, "5050-30D-30R". Through my research I had discovered that the LEDs are 5050's, however I can't identify what signal I need to write on the data wire to control the PCB. I have the FastLED library installed, but have had no luck getting anything to work as of yet. Any help would be appreciated. I am using a knock off Arduino Nano, and the led strip is listed below. https://www.homedepot.ca/product/tzumi-auraled-14-ft-colorstrip-led-adhesive-light-strip-kit-2-pack-/1001725590


r/ArduinoHelp • • Mar 29 '25

Help with h-bridge wiring

2 Upvotes

Hi all, I've been trying to create an h-bridge for a 5v DC motor using an Arduino Nano, and I'm trying to control it with the Arduino IDE. I've been trying to find something online to help me, but I couldn't find anything. I've seen people using an h-bridge module, but I'd rather use the 2 PNPs and 2 NPNs. Any help would be great. Thanks, and have a great day.


r/ArduinoHelp • • Mar 27 '25

BMP180 and BMP280 not responding at all

Thumbnail
gallery
2 Upvotes

I am experiencing issues with two sensors connected (tested) via I2C to NodeMCU v3 and Nano. Despite using different sketches, libraries, and hardware configuration, but sensors do not respond to i2c scans or output any data. I have checked connections, added pull-up resistors, ensured proper power supply, but the problem persists. Both sensors behave identically. Could you share your views on this topic?


r/ArduinoHelp • • Mar 12 '25

What app do I need to control this robot

Post image
2 Upvotes

I lost the manual and deleted the app years ago and now I can't remember what app controls it


r/ArduinoHelp • • Feb 25 '25

How many stepper motors and servo motors should I use?

2 Upvotes

I am making a project using an arduino mega 2560, is it possible to connect 8 servo motors and 1 stepper motor? If it is possible is there anything I should know? Like what voltage or anything else to help? This is also my first project so any help at all would be appreciated!


r/ArduinoHelp • • Jan 27 '25

Is my Arduino broken or is it a temporary glitch?

Post image
2 Upvotes

Suddenly some things started to work incorrectly in the project I was working on.

To find the source of the problem I went simple and uploaded a code to my Arduino that would just turn on and off an LED.

It also didn't work and I checked pins, some pins are randomly turns LED on some of doesn't.

And I guess reset button also does nothing. Is my arduino dead or something else?


r/ArduinoHelp • • Jan 23 '25

I need help! Issue with my Arduino Nano

2 Upvotes

Hello. I need your help please.

I got a Arduino Nano and this error keeps appearing to me. I already got the drivers for it

Check it out, this is the one I have bought. https://produto.mercadolivre.com.br/MLB-3544927205-arduino-nano-compativel-v3-atmega328-ch340-pino-sold-c-cabo-_JM

This is the weird error message.

Sketch uses 924 bytes (3%) of program storage space. Maximum is 30720 bytes.

Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x20

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x20

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x20

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x20

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x20

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x20

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x20

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x20

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x20

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x20

Failed uploading: uploading error: exit status 1


r/ArduinoHelp • • Jan 20 '25

1602 not displaying

Post image
2 Upvotes

I followed a tutorial and


r/ArduinoHelp • • Jan 19 '25

Issues with timers and LEDs on ESP32-CAM

2 Upvotes

Hello,

I am in the middle of a project that is in honor of my friend who past away last year. Long story short, I need an automated device to take a picture every hour. The full project scope is this:

ESP32-Cam takes a photo every hour

A red LED flashes for X seconds before the photo is taken

A light sensor determines whether or not to use the onboard flash LED

This is my very first project using Arduino IDE, though I am familiar with ESP Home and basic programming logic. Right now I am just trying to get the camera to take a phot, write to the sd card, and have the red led flashing for 8 seconds and onboard flash led on for 4 seconds before the photo. The code I have now (written by Claude AI) has the red LED flashing as a test at startup (which works) but both LEDs do not function as they should before the picture is taken. The camera does not have an issue taking the picture and writing to the sd card, and the flash led does come on briefly for the photo but not long enough to reach full brightness. The red led only flashes on startup. Any help would be greatly appreciated.

Code:

#include "esp_camera.h"
#include "Arduino.h"
#include "FS.h"
#include "SD_MMC.h"
#include "soc/soc.h"
#include "soc/rtc_cntl_reg.h"
#include "driver/rtc_io.h"

// Pin definitions
#define FLASH_LED_PIN 4     // Onboard flash LED
#define RED_LED_PIN 12      // External red LED
#define PWDN_GPIO_NUM     32
#define RESET_GPIO_NUM    -1
#define XCLK_GPIO_NUM      0
#define SIOD_GPIO_NUM     26
#define SIOC_GPIO_NUM     27
#define Y9_GPIO_NUM       35
#define Y8_GPIO_NUM       34
#define Y7_GPIO_NUM       39
#define Y6_GPIO_NUM       36
#define Y5_GPIO_NUM       21
#define Y4_GPIO_NUM       19
#define Y3_GPIO_NUM       18
#define Y2_GPIO_NUM        5
#define VSYNC_GPIO_NUM    25
#define HREF_GPIO_NUM     23
#define PCLK_GPIO_NUM     22

// Timing constants (all in milliseconds)
const unsigned long CYCLE_DURATION = 30000;  // 30 seconds
const unsigned long RED_LED_START = 8000;    // Red LED starts 8 seconds before photo
const unsigned long FLASH_LED_START = 4000;  // Flash LED starts 4 seconds before photo
const unsigned long BLINK_INTERVAL = 500;    // Red LED blinks every 500ms
unsigned long lastBlinkTime = 0;
unsigned long cycleStartTime = 0;
bool redLedState = false;

// Photo counter for filename
unsigned int photoCount = 0;

void setup() {
  // Initialize UART for debugging
  Serial.begin(115200);
  delay(1000); // Give serial time to initialize
  
  Serial.println("\n\n=== ESP32-CAM Starting ===");
  Serial.println("1. Serial initialized");

  // Disable brownout detector
  WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);
  Serial.println("2. Brownout detector disabled");

  // Configure LED pins
  pinMode(RED_LED_PIN, OUTPUT);
  digitalWrite(RED_LED_PIN, LOW);
  pinMode(FLASH_LED_PIN, OUTPUT);
  digitalWrite(FLASH_LED_PIN, LOW);
  Serial.println("3. LED pins configured");

  // Test red LED
  Serial.println("4. Testing RED LED (4 blinks)...");
  for(int i = 0; i < 4; i++) {
    digitalWrite(RED_LED_PIN, HIGH);
    Serial.println("   RED LED ON");
    delay(500);
    digitalWrite(RED_LED_PIN, LOW);
    Serial.println("   RED LED OFF");
    delay(500);
  }
  Serial.println("5. LED test complete");

  // Initialize camera
  camera_config_t config;
  config.ledc_channel = LEDC_CHANNEL_0;
  config.ledc_timer = LEDC_TIMER_0;
  config.pin_d0 = Y2_GPIO_NUM;
  config.pin_d1 = Y3_GPIO_NUM;
  config.pin_d2 = Y4_GPIO_NUM;
  config.pin_d3 = Y5_GPIO_NUM;
  config.pin_d4 = Y6_GPIO_NUM;
  config.pin_d5 = Y7_GPIO_NUM;
  config.pin_d6 = Y8_GPIO_NUM;
  config.pin_d7 = Y9_GPIO_NUM;
  config.pin_xclk = XCLK_GPIO_NUM;
  config.pin_pclk = PCLK_GPIO_NUM;
  config.pin_vsync = VSYNC_GPIO_NUM;
  config.pin_href = HREF_GPIO_NUM;
  config.pin_sscb_sda = SIOD_GPIO_NUM;
  config.pin_sscb_scl = SIOC_GPIO_NUM;
  config.pin_pwdn = PWDN_GPIO_NUM;
  config.pin_reset = RESET_GPIO_NUM;
  config.xclk_freq_hz = 20000000;
  config.pixel_format = PIXFORMAT_JPEG;

  Serial.println("6. Camera config structure initialized");

  if(psramFound()){
    config.frame_size = FRAMESIZE_UXGA;
    config.jpeg_quality = 10;
    config.fb_count = 2;
    Serial.println("7. PSRAM found - setting high resolution");
  } else {
    config.frame_size = FRAMESIZE_SVGA;
    config.jpeg_quality = 12;
    config.fb_count = 1;
    Serial.println("7. No PSRAM - setting lower resolution");
  }

  // Initialize the camera
  esp_err_t err = esp_camera_init(&config);
  if (err != ESP_OK) {
    Serial.printf("8. Camera init failed with error 0x%x\n", err);
    return;
  }
  Serial.println("8. Camera initialized successfully");

  // Initialize SD card
  if(!SD_MMC.begin()){
    Serial.println("9. SD Card Mount Failed");
    return;
  }
  uint8_t cardType = SD_MMC.cardType();
  if(cardType == CARD_NONE){
    Serial.println("9. No SD Card attached");
    return;
  }
  Serial.println("9. SD Card mounted successfully");

  // Initialize timers
  cycleStartTime = millis();
  lastBlinkTime = millis();
  
  Serial.println("10. Setup complete!");
  Serial.println("=== Entering main loop ===\n");
}

void loop() {
  unsigned long currentTime = millis();
  unsigned long timeInCycle = currentTime - cycleStartTime;
  
  // Print debug info every second
  static unsigned long lastDebugTime = 0;
  if (currentTime - lastDebugTime >= 1000) {
    Serial.printf("\nDEBUG: Time in cycle: %lu ms\n", timeInCycle);
    Serial.printf("DEBUG: Time until photo: %lu ms\n", CYCLE_DURATION - timeInCycle);
    Serial.printf("DEBUG: Red LED should be active: %s\n", 
                 (timeInCycle >= (CYCLE_DURATION - RED_LED_START)) ? "YES" : "NO");
    Serial.printf("DEBUG: Flash should be active: %s\n", 
                 (timeInCycle >= (CYCLE_DURATION - FLASH_LED_START)) ? "YES" : "NO");
    lastDebugTime = currentTime;
  }

  // Red LED Control - Blink during last 8 seconds
  if (timeInCycle >= (CYCLE_DURATION - RED_LED_START)) {
    // We're in the blinking period
    if (currentTime - lastBlinkTime >= BLINK_INTERVAL) {
      redLedState = !redLedState;
      digitalWrite(RED_LED_PIN, redLedState);
      lastBlinkTime = currentTime;
      Serial.printf("LED EVENT: Red LED switched to %s at cycle time %lu ms\n", 
                   redLedState ? "ON" : "OFF", timeInCycle);
    }
  } else {
    // Outside blinking period, ensure LED is off
    if (redLedState) {  // Only turn off and log if it was on
      digitalWrite(RED_LED_PIN, LOW);
      redLedState = false;
      Serial.println("LED EVENT: Red LED forced OFF (outside blink period)");
    }
  }

  // Flash LED Control - Stay on for last 4 seconds
  if (timeInCycle >= (CYCLE_DURATION - FLASH_LED_START)) {
    if (digitalRead(FLASH_LED_PIN) == LOW) {  // Only turn on and log if it was off
      digitalWrite(FLASH_LED_PIN, HIGH);
      Serial.printf("LED EVENT: Flash LED turned ON at cycle time %lu ms\n", timeInCycle);
    }
  } else {
    if (digitalRead(FLASH_LED_PIN) == HIGH) {  // Only turn off and log if it was on
      digitalWrite(FLASH_LED_PIN, LOW);
      Serial.printf("LED EVENT: Flash LED turned OFF at cycle time %lu ms\n", timeInCycle);
    }
  }

  // Take photo at end of cycle
  if (timeInCycle >= CYCLE_DURATION) {
    Serial.println("\n=== Starting photo sequence ===");
    
    // Additional warm-up time for flash if needed
    if (digitalRead(FLASH_LED_PIN) == LOW) {
      digitalWrite(FLASH_LED_PIN, HIGH);
      Serial.println("LED EVENT: Flash LED forced ON for photo");
      delay(2000);  // 2 second warm-up
    }
    
    takePhoto();
    
    // Reset everything for next cycle
    digitalWrite(FLASH_LED_PIN, LOW);
    digitalWrite(RED_LED_PIN, LOW);
    redLedState = false;
    
    // Get current time after all operations
    currentTime = millis();
    cycleStartTime = currentTime;
    lastBlinkTime = currentTime;
    
    Serial.println("=== Starting new 30-second cycle ===\n");
  }

  delay(5);  // Small delay to prevent overwhelming the processor
}

void takePhoto() {
  Serial.println("Getting camera frame buffer...");
  camera_fb_t * fb = esp_camera_fb_get();
  if (!fb) {
    Serial.println("Camera capture failed");
    return;
  }

  String filename = "/photo_" + String(photoCount++) + ".jpg";
  Serial.printf("Creating file: %s\n", filename.c_str());
  
  fs::FS &fs = SD_MMC;
  File file = fs.open(filename.c_str(), FILE_WRITE);
  if(!file) {
    Serial.println("Failed to create file");
  } else {
    file.write(fb->buf, fb->len);
    Serial.println("File saved");
  }
  file.close();
  esp_camera_fb_return(fb);
}