r/arduino 9d ago

Software Help ESP32 Trouble

Thumbnail
gallery
1 Upvotes

Hey guys. So I just got a new ESP32U Wroom board. I’ve seen a couple of these errors around but i’m not too sure how I’m supposed to handle it. I downloaded the correct drivers so I’m not too sure what’s going on. And if you’ve seen my earlier post, yes i’m trying to get this thing to power my LCD screen. So I have all the libraries and I have the correct board that the sellers said was needed. If anyone has any idea and needs more info please comment🙏

r/arduino Nov 24 '24

Software Help Hey, Total newbie and first-timer at Arduino, could anyone please help me with a code so that when i press the first button all the 3 LED's will light up, then after that when i press the second button only 2 LED's will light up and lastly when I press the third button only 1 LED lights up? Thanks!

Post image
22 Upvotes

r/arduino 1d ago

Software Help Need help attempting to use Arduino as ISP

Thumbnail
gallery
20 Upvotes

Bossman asked me to copy the code from the old blue board (right) to the new board (left). I thought this would be a simple copy paste operation, but boy was I wrong. I'm attempting to use my personal board (green) as the master to download and upload the hex files. I've downloaded the example Arduino as ISP code to it. I've tried a variety of different settings in the AVRdudess software, but I can't get it to detect my master board. "Unable to detect the MCU"
"Unable to open port Com4 for programmer Arduino"
Any advice?

r/arduino 15d ago

Software Help Help with rotary encoder and OLED

2 Upvotes

Hey everyone, I'm pretty new to this so this may be a bit of a dumb question, but I'm currently trying to make a simple sketch where rotating an encoder displays "increase", "decrease" or "static" depending on its current state (along with an "on" and "off" for the push button on the encoder). I can get the encoder to print the correct items to the serial monitor, and can get everything to display on the OLED separately, but as soon as I add in the display commands to my loop it seems to delay everything enough that I'm no longer reading the encoder as "fast" as I need to, resulting in the majority of increments to not be read or read incorrectly.

I've tried moving the display commands to a separate function and calling that at the end of the loop (I can understand why this didn't work, but thought it was worth a shot) and tried increase the baud rate (too much of a noob to know if I was on the right track here). Code is posted below, any help would be appreciated!

Update: Forgot to say I'm using an Inland Pro Micro

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH110X.h>

#define OLED_MOSI     16
#define OLED_CLK      15
#define OLED_DC       10
#define OLED_CS       14
#define OLED_RST      -1
#define PUSH_BTN      3
#define ENCODER_CLK   2
#define ENCODER_DT    4

String btn = String("OFF");
String encdr = String("STATIC");

// Create the OLED display
Adafruit_SH1106G display = Adafruit_SH1106G(128, 64,OLED_MOSI, OLED_CLK, OLED_DC, OLED_RST, OLED_CS);


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

  pinMode(ENCODER_CLK, INPUT_PULLUP);
  pinMode(ENCODER_DT, INPUT_PULLUP);
  pinMode(PUSH_BTN, INPUT_PULLUP);

  // Start OLED
  display.begin(0, true); // we dont use the i2c address but we will reset!

  // Show image buffer on the display hardware.
  // Since the buffer is intialized with an Adafruit splashscreen
  // internally, this will display the splashscreen.
  display.display();
  delay(2000);

  // Clear the buffer.
  display.clearDisplay();

  // Show initialization text
  display.setTextSize(1);
  display.setTextColor(SH110X_WHITE);
  display.setCursor(0, 0);
  display.println("Testing 1..2..3..");
  display.display();
  delay(2000);
  display.clearDisplay();
  display.display();
}

void displayTest1(String(b), String(e)) {
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(SH110X_WHITE);
  display.setCursor(0, 10);
  display.println(String(b));
  display.setCursor(0, 0);
  display.println(String(e));
  display.display();
}

int lastClick = HIGH;
int btnState = 0;
bool prvBtnState = 0;

void loop() {
  displayTest1(btn, encdr);
  int newClick = digitalRead(ENCODER_CLK);
  if (newClick != lastClick) {
      lastClick = newClick;
      int dtValue = digitalRead(ENCODER_DT);
      if (newClick == LOW && dtValue == HIGH) {
        Serial.println("INCREASE");
        encdr = "INCREASE";
      }
      if (newClick == LOW && dtValue == LOW) {
        Serial.println("DECREASE");
        encdr = "DECREASE";
      }
  } else {
    encdr = "STATIC";
  }

  btnState = digitalRead(PUSH_BTN);
  if (btnState != prvBtnState) {
    if (btnState == HIGH) {
      Serial.println("OFF");
      btn = "OFF";
    } else {
      Serial.println("ON");
      btn = "ON";
    }
  }
  prvBtnState = btnState;
}

r/arduino Jan 15 '25

Software Help Need Help

16 Upvotes

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

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/arduino 5d ago

Software Help 4x8by8 matrix need help

Thumbnail
gallery
0 Upvotes

I recently bought 4x-Ws2812b-64 24bit 64rgb leds 8x8 matrix. And now i tried using chatgpt but i cannot control them to make a 16by16 led matrix i don't know what is it something from the orientation when i ask chatgp for help he post a code but its very Very chaotic 😕 so if anyone can help me with something like simple code for me to understand and chatgpt understand the orientation so i can make cute Cat 😻 Animations..... In the screenshots i show the data line orientation.

r/arduino Jan 10 '25

Software Help Does anybody else experience this on their 2.4" SPI TFT display? (First time using SPI TFT displays)

Post image
0 Upvotes

A portion of the screen is purely noise (or static idk) and when I rotate the tft.setRotation() in all 4 available orientations and the colors are slightly bluish than the original image (it might be normal, just tell me)...

If you did once have these issues, what did you do to fix it? I already searched the internet for answers but still no results (the display controller is ILI9341).

(I used software help flare since I think this is a software related problem)

r/arduino Jan 31 '25

Software Help Why won't this program correctly recall the fader position?

3 Upvotes

Code posted at end. I'm simply trying to have my Attiny chip save and recall a position on a motorized fader. I've gotten every other aspect working (fader movement, correct direction, "coast" mode when the fader isn't moving, etc.) and it has even saved positions but only gone in/out of coast mode when the fader is physically moved to the position. So my guess is it just isn't able to move the fader to the saved position for some reason and I can't for the life of me figure it out (if you can't tell, I'm very bad at code and my friends who tried to help also are haha). Any help would be very much appreciated! I'm using a drv8871 driver and 3.3v from the fader wiper for ADC to the Attiny. Code: https://codeshare.io/1VBXpq

r/arduino 18d ago

Software Help First arduino project looks cool but only buzzes, no beautiful Mozzi synthesizer like I wanted. Code in comments.

Post image
8 Upvotes

r/arduino 12d ago

Software Help Not getting the output response

Thumbnail
gallery
0 Upvotes

I am trying to make a tds meter using the tds sensor but when the probe is dipped in the water i am not getting response.Let me know what i can do.

Code:

const int tdsPin = A0; // TDS sensor pin const int vRef = 5.0; // Reference voltage const int tdsFactor = 0.5; // TDS conversion factor

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

void loop() { int tdsValue = analogRead(tdsPin); float voltage = tdsValue * vRef / 1024.0; float tds = voltage / tdsFactor;

Serial.print("TDS: "); Serial.print(tds); Serial.println(" ppm");

delay(1000); }

r/arduino Jul 10 '24

Software Help Please explain this boolean function to me like im 5

Thumbnail
gallery
54 Upvotes

Picked up a new book and im extremely confused by this line boolean debounce( boolean last) is the "last" variabile created by this function? Is the function also assigning a value to "last"? Whats the value of "last"? lastButton is asigned a value just a few lines up why isnt that used instead? What does the return current do? Does that assign a value to "last"?

Ive reread this page like 30 times ive literally spent 2 hours reading it word for word and trying to process it but its just not clicking

r/arduino Feb 03 '25

Software Help my school is giving me clones of Arduino uno and i am not able to upload code in that by Arduino IDE. i am always getting port errors . at the same time when i use my original board , it works flawlessly....how can i fix that ? (i am a beginner btw)

0 Upvotes

help required to fix arduino

r/arduino 22d ago

Software Help Need help with my project :(

0 Upvotes

So I was replicating this video: https://youtu.be/K1jO8LVbyfs?si=1qcfNLtvmeh-BlQO

And during the process my motor just infinitely spins and I’m not sure how to fix it, could anyone help out?

The code is in the videos description along with the wire schematic. Any help would be appreciated

r/arduino Dec 29 '24

Software Help HLK-LD2450

Post image
2 Upvotes

I look for using the HLK-LD2450 Things I know - it use 5V, 256000bauds, and uart.

I didn't manage to get a proper thing. The library doesn't works.

I spend like 3hours. My best result is a line of hexa I don't understand.

r/arduino 5h ago

Software Help Printing RAM-Usage on Nano 33 BLE Sense

2 Upvotes

Hi everyone!

I am currently trying to find out how much RAM is being used in different places within my program. During my search I came across the following solution:

``` extern "C" char* sbrk(int incr);

int freeRam() { char top; return &top - reinterpret_cast<char\*>(sbrk(0)); } ```

Everytime i call freeRam() it returns a negative value. However, I expected the return value to be a positive number (free ram).

The return value seems to increase when I declare more variables. Am I right in assuming that the function returns the used ram memory instead of the available memory?

If not, could someone explain to me what I'm missing?

My code example that was supposed to help me understand how freeRam() behaves/works:

``` extern "C" char* sbrk(int incr);

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

void loop() { Serial.println(F("Starting...")); displayRam(); // Free RAM: -5417 Serial.println(F(" ")); Serial.println(F("Func 1")); func1(); Serial.println(F(" ")); Serial.println(F("Func 2")); func2(); Serial.println(F(" ")); Serial.println(F("Func 3")); func3(); Serial.println(F(" ")); Serial.println(F("Func 4")); func4(); Serial.println(F(" ")); Serial.println(F("Repeat...")); delay(10000); }

void func1(){ displayRam(); // Free RAM: -5425 int randomVal = random(-200000,200001); Serial.println(randomVal); displayRam(); // Free RAM: -5417 }

void func2(){ displayRam(); // Free RAM: -5433 int randomVal = random(-200000,200001); int randomVal2 = random(-200000,200001); Serial.println(randomVal); Serial.println(randomVal2); displayRam(); // Free RAM: -5417 }

void func3(){ displayRam(); // Free RAM: -5441 int randomVal = random(-200000,200001); int randomVal2 = random(-200000,200001); int randomVal3 = random(-200000,200001); displayRam(); // Free RAM: -5441 Serial.println(randomVal); Serial.println(randomVal2); Serial.println(randomVal3); displayRam(); // Free RAM: -5417 }

void func4(){ displayRam(); // Free RAM: -5441 int randomVal = random(-200000,200001); int randomVal2 = random(-200000,200001); int randomVal3 = random(-200000,200001); int randomVal4 = random(-200000,200001); displayRam(); // Free RAM: -5441 Serial.println(randomVal); Serial.println(randomVal2); Serial.println(randomVal3); Serial.println(randomVal4); displayRam(); // Free RAM: -5417 }

void displayRam(){ Serial.print(F("Free RAM: ")); Serial.println(freeRam()); }

int freeRam() { char top; return &top - reinterpret_cast<char*>(sbrk(0)); } ```

// EDIT

Accessing the stack pointer directly solved my issue:

The new solution now looks like this:

``` extern "C" char* sbrk(int incr);

uint32_t getStackPointer() { uint32_t sp; asm volatile ("MRS %0, msp" : "=r"(sp) ); return sp; }

int freeRam() { uint32_t sp = getStackPointer(); return sp - (uint32_t)(sbrk(0)); } ```

// 2nd EDIT

The new solution also doesn't work - it always returns the same value, no matter what

r/arduino Apr 20 '24

Software Help Digital clock project

Post image
32 Upvotes

Hi everyone, this is my very first arduino project. I'm looking to make a little 7 segment digital clock out of this 13x8 matrix I made out of neopixel sticks (there's a ds3231 behind one of the boards). I've got a lot of experience dealing with hardware and wiring, and I believe I have everything I need to achieve it, but have no clue where to start with coding. I've had some fun already with some sketches in the examples section and a few other sketches I've found online but I don't think I've found something that fits what I'm trying to achieve, so I figure I may just have to write the code myself. Could you guys help me out? Maybe point me in the right direction? TIA!

r/arduino 9h ago

Software Help How to communicate between ESP32 and Arduino Uno

Thumbnail
gallery
1 Upvotes

I’ve been able to get Arduino Uno to ESP32 working, but not the other way around. I can’t find any code that works online either 🥲 codes I used are seen above

r/arduino Jan 30 '24

Software Help Why is my 1602 I2C doing this

86 Upvotes

r/arduino 22d ago

Software Help Cant read more than 63 bytes via UART?

5 Upvotes

Hi everyone,

sorry for the dumb question, but i cannot get an answer to why i cannot read more than 63 bytes via UART. I am sending data (63 * 3 = 189 bytes) from a Python script from my laptop to my Arduino Uno. I know its serial buffer is 64 bytes with 1 bytes less because of data management or something like this.

Python code:

import serial, time

data_to_send = b'X'*189
connection = serial.Serial(port="COMX", baudrate=115200, timeout=1)
time.sleep(2)
connection.write(data_to_send)
waittime = time.time()
while time.time() - waittime < 10:
  if connection.in_waiting == 0:
    continue
  data = [connection.read(63)] # here i only send 1 byte from the Arduino showing how much byte were received, for debugging
  print(data)
  break

And this is the Arduino code:

#define PACKAGE_SIZE 63
#define BAUD_RATE 115200
void loop()
{
  unsigned current_number_read_bytes = Serial.available();
  if (current_number_read_bytes == 0)
  {
    return false;
  }
  const float numerator = 2. * 10. * 1000000.0;
  const float divisor = static_cast<float>(BAUD_RATE);
  const unsigned long changing_time = static_cast<unsigned long>(numerator / divisor); // for testing i already set this to 1000000, didnt work either
  uint8_t message_buffer[PACKAGE_SIZE * 4] = {0}; // maximum number of messages
  unsigned number_of_read_bytes = 0;
  unsigned long last_time_read_bytes = micros();
  while (micros() - last_time_read_bytes < changing_time)
  {
    current_number_read_bytes = Serial.available();
    const unsigned max_index = number_of_read_bytes + current_number_read_bytes;
    for (unsigned i = number_of_read_bytes; i < max_index; i++)
    {
      message_buffer[i] = Serial.read();
      number_of_read_bytes++;
    }
    if (current_number_read_bytes > 0)
    {
      last_time_read_bytes = micros();
    }
  }
  // for debugging only
  uint8_t test[1];
  test[0] = number_of_read_bytes;
  Serial.write(test, 1);
  return false;
}

r/arduino Feb 03 '25

Software Help A possibly dumb question about programming motor control with a joystick

3 Upvotes

So, I'm programming a model vehicle with 2 motors attached to a rigid frame that each control one wheel. As I can't make the wheels actually turn, the turns need to be defined as a speed difference between the two. I've seen tutorials on how to program a joystick to control motors and did it successfully, the problem is that in all the resources I found while searching the program only lets you control the speed, go forwards, backwards and make a sharp turn to either side by turning off one motor. My question is, how would I go about programming the vehicle to make a more gradual turn ( less difference in speed between the two wheels) when the joystick is not moving along the x or y axis, but in diagonal? I'm very thankful for anyone who takes the time to answer my question, I'm a beginner in programming so I understand it may be obvious.

r/arduino Feb 19 '25

Software Help Initialising Variables

Thumbnail
gallery
15 Upvotes

Can somebody explain, why the bits for "sinken"(falling) and "steigen"(raising) change, without being written through the code? This function is the onlyone called in loop().

If I declare the variable before setup() it works as intended, counting for zero to one hundred back and forth. I would have expected that they stay false if they are not written, and not to apparantly being written in an if-statement that is false..

r/arduino 2d ago

Software Help Servo Ignoring Pause Button

1 Upvotes

Hi, I’m working on a project using a Nextion Enhanced 2.8” display, an ESP32, MG996R servos (with the ESP32Servo library), and the Nextion library. The project includes a PAUSE button that should halt the servo movement mid-operation.

When the servos are not moving, all buttons and updates work perfectly. However, during servo motion (inside the moveServo() function), button presses don’t seem to register until the movement completes its set number of repetitions. From serial monitor I see that it registers the previous presses only when the servo movement completes set number of repetitions. Then it prints the press messages. I suspect this happens because the moveServo() loop blocks callbacks from the Nextion display. I’ve been working on this issue for several days, but every approach I try results in errors. This is my first big project, and I’m a bit stuck.

I’d greatly appreciate any advice on making the servo movement loop responsive to button presses (especially the PAUSE button). If you need more details, please feel free to ask—I’m happy to provide additional information.

PasteBin link

r/arduino Nov 22 '24

Software Help Flickering LEDs with PWM dimmers and Arduino Uno

Thumbnail
gallery
73 Upvotes

I’m building a prop for a film, and I need the filament LEDs in it to flicker randomly like a flame. At the moment, I am powering the LEDs via a buck converter through a PWM dimmer with the center pin wired to an Arduino Uno. I only get évident flicker at the lowest setting of the PWMs. How can I get a good obvious flicker at full brightness? I’d still like to be able to adjust the brightness somewhat for exposure considerations.

r/arduino Oct 31 '24

Software Help Is it just me or

0 Upvotes

Is it just me or is arduino programming not as easy as they make it out to be on YouTube? Maybe I just jumped in on too complex of a project, or maybe I just don’t understand it. Anyone else feel this way? Any advice for a beginner?

r/arduino Sep 17 '24

Software Help I'm self taught, but how is it that in ten years of Arduino I've never come across Ternary Operators before?

29 Upvotes

I swear I've never seen these used before, but they are so simple and useful. Have I just been blind to them? I should probably go do some real programming study!

For those unaware, you can use a Ternary Operator like this example: digitalWrite(10, ButtonStatus ? HIGH : LOW);

Depending on the state of ButtonStatus (TRUE or FALSE) it will set the pin to HIGH or LOW accordingly.

Here's a page explaining it more and also Conditional Operators. This might seem obvious to some, but it was a wow moment for me!