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 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 20 '25

Why doesn't It work?(Novice)

Thumbnail
gallery
2 Upvotes

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 11 '25

ESP32 + MQTT: Solving step-pattern latency issues in real-time data visualization (with graph)

2 Upvotes

Hi! I'm part of a collegiate rocket team which is using an ESP32 to collect telemetry data, which we send to our device over MQTT, and plot the values received against the time which our visualization script receives the data.

When running tests with a simple script that increments a counter on every iteration, we've noticed that the data isn't sent over the network smoothly, but seems to be sent in bursts. (image 1)

However, when running the same publishing logic in a python script on our laptops where the broker is running, we get a graph with a much smoother progression. (image 2)

We're kind of new to MQTT, so we were wondering if the right conclusion to come to here was that such network latencies were inevitable and that we should be doing the timestamping of data on our ESP32 instead?


r/ArduinoHelp • • Apr 07 '25

Breadboard power supply for Centrifugal motor?

Post image
2 Upvotes

Hello! I’ve been working on a little setup for a plant auto waterer, and I’ve been struggling to get the centrifugal power motor working.

Can I use this breadboard power supply to power the centrifugal motor, or do I need a motor driver or similar device?

Is a 4N35, a 74HC138, or a 74HC595 any good for this? They also come in the pack, but looking up seems to confuse me more than anything.

I’ve also seen that the L9110S motor chip can be used, should I purchase that to power the motor? Thank you for the help!


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 • • 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 21 '25

Stuck on upload

2 Upvotes

I'm very new to arduino, and while trying to upload code on a new computer I keep getting stuck here. any advice? Edit: resolved! My pc hadn't assigned a COM to the nano, because 3 and 4 were taken I think. I just had to go into the device manager to assign it to COM5 and it works now


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 • • Feb 15 '25

Temp probe with 2mm diameter?

2 Upvotes

Hi, I'm trying to figure out what kind of temperature probe I can use to monitor temperature from two geothermal holes. The piping has an access port for a think sensor (about 2mm in diameter) to get in contact with the fluid, but I'm not sure what would be the appropriate sensor to use and are looking for ideas.

The temperature range is between -5 to +10 degrees, and the accuracy need to be fairly accurate (0.1 C or less). I can do proper calibration, so as long as the deviation is linear I can compensate in code.

I'm finding thermocouple and RTDs that have proper dimensions, but I'm not sure which would be better/worse and/or easiest to implement. I'll probably use ESP8266s for reading them (because I have spares and they have WiFi), which has a 12-bit analog input that probably could be used. Normally I use DS18b20 sensors because they are trivial to read, but seems like you can't find them in such thin packages.

Anyone has any suggestions?


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 22 '25

Please Help

2 Upvotes

Is there a way to get feedback from games? Like learning if a block is mining right now in minecraft. Then sending it into arduino using bluetooth. Sorry for writing mistakes. English is not my native language.


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);
}

r/ArduinoHelp • • Jan 15 '25

Need Help

2 Upvotes

Title: Need Help with Arduino Maze-Solving Robot (Left Wall-Following Method)

Have less than 10 hours to make this ready please help

Description:
I'm building an Arduino-based maze-solving robot using the left wall-following method and need assistance. Here's my setup:

  • 3 ultrasonic sensors (front, left, right)

  • 2 mini motors controlled by an L298N motor driver

  • 3.7V battery powering both the L298N and Arduino

Problem:
The robot spins in circles when I test the current code (which is not the expected behavior). I've reversed the motor wiring on the L298N, but the issue persists.

What I need help with:

  1. A working code to implement the left wall-following method.

  2. Proper turning logic to ensure the robot accurately follows the left wall.

  3. Correct motor control, accounting for reversed wiring.

Any help would be appreciated! I have only less than 10 hours to make this ready

Made this using here https://maker.pro/arduino/projects/how-to-build-an-arduino-based-maze-solving-robot


r/ArduinoHelp • • Jan 04 '25

MG90 motor not working with signal

Post image
2 Upvotes

Hi friends, I am trying to make an MG90 servo motor work back / forth when I touch a proximity sensor. Circuit diagram attached. I am using an Arduino nano without a serial number. I put an LED between the yellow wire and the black wire at the input of the motor to check if the motor is getting signal from Arduino or not and I am seeing that it’s getting the signal as the LED stops light when I touch the proximity sensor and lights up again when I move away from the sensor. The input voltage to the motor is around 5v, so the voltage may not be the issue. I also observed that the motor works sometimes properly but 90% of the time it doesn’t work. Can you please help me understand the root cause of this… Thank you!


r/ArduinoHelp • • Dec 28 '24

Need guidance

Post image
2 Upvotes

r/ArduinoHelp • • Dec 27 '24

Arduino board identification trouble / what does it do? / what else can I make it do?

2 Upvotes

I am new to using Arduino and I have this board that I ordered from amazon a while ago. I was able to connect it with the Arduino IDE and upload the code into it. I modified the blink default program and it is 100% able to be connected and compatible. However, I want to figure out what else I can do with this specific board other than just blinking an LED differently. Please let me know if you know what board this is and/or what else this specific model can be used for. I tried the internet but am still having trouble finding instructions for this specific board and figuring what it does exactly and how to do it. Do I need to buy sensors or other parts for this one?


r/ArduinoHelp • • Dec 25 '24

NEMA 17 Stepper Motor with MKS SERVO42A and GenL V2.1 - No Device Detected

2 Upvotes

Hi all,

I am working on setting up a smart stepper motor using MKS SERVO42A board and Gen LV2.1 motherboard. It is powered using 24 DC supply and I am using the firmware corresponding to Misfittech Stepper Nano (https://github.com/Misfittech/nano_stepper).

I am using the setup to drive a linear rail system for the time being. However, my board is not being detected by my PC. There is a driver (https://github.com/makerbase-mks/MKS-SERVO42A/tree/master/Firmware) that is required as per Misfittech and MKS. But, it keeps failing. Would appreciate some advice!

Apologies if this is not the correct avenue for this!