/r/arduino
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! 😉
A reddit for all things Arduino.
r/Arduino Information:
Arduino Information:
Related Subreddits:
Beginners:
Where to buy:
Tools / References:
Wokwi Arduino Simulator ✨ New!
/r/arduino
So I got some cheap christmas lights, but turns out they only work when you push a button after you turn on power. I want them to work on a timer, so this doesn't work for me.
I have an Arduino Uno lying around so I thought I could just make my own controller for it, but when I opened it up and checked the connections, I'm a bit stumped.
There's basically 3 connections going to the LEDs to make the twinkling pattern (4 wires, but 2 are just soldered to the same connector). L1, L2 and L3. There's no separate - or ground wire, and after some testing, it turns out that there are 4 combinations to light up the different LEDs:
+ L1 - L3
+ L2 - L3
+ L3 - L1
+ L3 - L2
Turns out every connection can be both + or - depending on what LED you want to power. But I have no idea how to start with something like this on the arduino. I basically just want to cycle the different LEDs to recreate the twinkling effect.
Can anyone help this total arduino beginner?
#include <WiFi101.h>
#include <WiFiSSLClient.h>
#include <UniversalTelegramBot.h>
#include <ArduinoJson.h>
// WiFi credentials
char ssid[] = "ssid"; // Replace with your WiFi SSID
char pass[] = "password"; // Replace with your WiFi password
// Telegram bot credentials
#define BOT_TOKEN "token" // Replace with your bot token
#define CHAT_ID "chat id" // Replace with your chat ID
WiFiSSLClient client; // Secure client for HTTPS
UniversalTelegramBot bot(BOT_TOKEN, client); // Telegram bot instance
#if defined(ARDUINO_ARCH_SAMD)
#define SMI SerialUSB
#else
#define SMI Serial
#endif
void setup() {
SMI.begin(9600);
while (!SMI) {
; // Wait for Serial port to initialize
}
SMI.println("=== Starting Setup ===");
// Check WiFi shield presence
if (WiFi.status() == WL_NO_SHIELD) {
SMI.println("WiFi shield not present. Check hardware configuration.");
while (true); // Halt execution if no WiFi shield is present
}
// Configure pins for TinyZero
WiFi.setPins(8, 2, A3, -1);
// Connect to WiFi network
SMI.println("Connecting to WiFi...");
WiFi.begin(ssid, pass);
int wifi_attempts = 0;
while (WiFi.status() != WL_CONNECTED && wifi_attempts < 10) {
SMI.print(".");
delay(5000);
wifi_attempts++;
}
if (WiFi.status() == WL_CONNECTED) {
SMI.println("WiFi connected!");
printWiFiStatus();
} else {
SMI.println("Failed to connect to WiFi. Restarting...");
while (true); // Halt if WiFi fails
}
// DNS Resolution Test
IPAddress telegramIP;
if (WiFi.hostByName("api.telegram.org", telegramIP)) {
SMI.print("Telegram Server IP resolved: ");
SMI.println(telegramIP);
} else {
SMI.println("Failed to resolve Telegram server address. Check DNS settings.");
while (true);
}
// Send a test message to Telegram Bot
SMI.println("Sending test message to Telegram Bot...");
String message = "Hello from TinyZero!";
if (bot.sendMessage(CHAT_ID, message, "")) {
SMI.println("Message sent successfully!");
} else {
SMI.println("Failed to send message to Telegram Bot. Verify credentials and connection.");
}
}
void loop() {
// Example: Periodically send a test message every 30 seconds
delay(30000);
SMI.println("Sending periodic message to Telegram Bot...");
String message = "This is a periodic message from TinyZero.";
if (bot.sendMessage(CHAT_ID, message, "")) {
SMI.println("Periodic message sent successfully!");
} else {
SMI.println("Failed to send periodic message to Telegram Bot. Verify credentials.");
}
}
// Function to print WiFi connection details
void printWiFiStatus() {
SMI.print("SSID: ");
SMI.println(WiFi.SSID());
IPAddress ip = WiFi.localIP();
SMI.print("IP Address: ");
SMI.println(ip);
long rssi = WiFi.RSSI();
SMI.print("Signal strength (RSSI): ");
SMI.print(rssi);
SMI.println(" dBm");
}
this was my code, my wifi board is WiFi TinyShield (ATWINC1500) ASD2123-R, but i'm unsure what is the issue here. can anyone help out?
hi everyone, i need sensor suggestions. I have to make iot mini project, but i have no basic.
so, i want to make two wearable device for child monitoring where the parents (receiver) will get alerted if the child (transmitter) distance is greater than 10M away from parent.
The alert will be in the form of buzzer and also notifications from phone.
is there suitable sensor that i can use?
(the distance can be changed within the sensor capabilities)
Update: currently, im planning on using HC-SR04 sensor but with my research, it is maximum of 4M distance, i do not mind it, is HC-SR04 okay for my project?
Hey, I'm an IT undergraduate with almost no experience with Arduino, and I would really appreciate your support for my university hardware project. My team and I are willing to prepare a proposal of an Automatic Storage and Retrieval System (ASRS) with horizontal and vertical linear belt-driven actuators working on aluminum profiles and V-wheel gantry plates.
Here’s a basic rundown of the system:
We will be using a 5x5 rack to demonstrate the storage space.
A box will be provided with a small clearance underneath for the system's fork to pick it up.
The vertical actuator will sit on the gantry plate of the horizontal actuator.
When the store command is given, the horizontal actuator will move to the box (placed in a predefined position), and the vertical actuator will move accordingly, using the fork attached to the plate of the vertical actuator to pick up and store the box in the provided cell of the 2D rack matrix.
We have chosen to go with Arduino Uno, NEMA 17 stepper motors, CNC shield, A4988 stepper motor drivers, idler pulleys, timing belts, and timing pulleys.
Will we need another small belt-driven actuator to move the fork front and back (requiring another motor to sit on the vertical actuator), or is there a simpler way to achieve this?
As we are willing to use AccelStepper Library, the positions of the cells can be predefined. But will we still need a limiting switch just in case on either side of the actuators?
Is there a specific method to mount the vertical actuator on the horizontal gantry plate steadily?
If you have any further advice on optimizing the design or potential improvements, that would be much appreciated!
I just tried to install bootloader on Arduino Nano. For some reason the bootloader is not loading.
Error message:"C:\Users\nerim\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\nerim\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -patmega328p -cstk500v1 -PCOM7 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDA:m -Ulfuse:w:0xFF:m
avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:\Users\nerim\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"
Using Port : COM7
Using Programmer : stk500v1
Overriding Baud Rate : 19200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x03
avrdude done. Thank you.
Failed chip erase: uploading error: exit status 1
#include <Arduino.h>
// Define pins
#define PWMA 6
#define PWMB 5
#define DIRA 7
#define DIRB 4
#define IR_LEFT A7
#define IR_RIGHT A6
#define CDS_LEFT_2_PIN 10
#define CDS_RIGHT_2_PIN 9
#define trigPin A0
#define echoPin A1
// Constants
const int DISTANCE_THRESHOLD = 5; // Obstacle detection threshold (cm)
const int MOTOR_SPEED = 150; // Base motor speed (PWM)
const unsigned long TURN_INTERVAL = 500; // Turning duration (ms)
const float K_p = 10; // PID proportional gain
const float K_i = 0.5; // PID integral gain
const float K_d = 8; // PID derivative gain
const float MAX_INTEGRAL = 10; // Maximum integral value to avoid excessive error accumulation
// Global variables
unsigned long lastTurnTime = 0;
float integral = 0;
float previousError = 0;
int rightSensorCount = 0;
// Turn handling logic
void handleTurn() {
static bool rightSensorLastState = HIGH;
static bool leftSensorLastState = HIGH;
bool rightSensorState = digitalRead(CDS_RIGHT_2_PIN);
if (rightSensorState == LOW && rightSensorLastState == HIGH) {
rightSensorCount++;
Serial.print("Right sensor count: ");
Serial.println(rightSensorCount);
if (rightSensorCount == 4 || rightSensorCount == 6) {
Serial.println("Turning right...");
controlMotor(MOTOR_SPEED, MOTOR_SPEED, HIGH, LOW);
delay(TURN_INTERVAL);
}
}
rightSensorLastState = rightSensorState;
bool leftSensorState = digitalRead(CDS_LEFT_2_PIN);
if (leftSensorState == LOW && rightSensorState == LOW) {
Serial.println("Turning left...");
controlMotor(MOTOR_SPEED, MOTOR_SPEED, LOW, HIGH);
delay(TURN_INTERVAL);
}
}
// Measure distance using ultrasonic sensor
float getDistance() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
float duration = pulseIn(echoPin, HIGH);
return (duration * 0.034 / 2); // Calculate distance in cm
}
// Motor control function
void controlMotor(int speedA, int speedB, bool dirA, bool dirB) {
digitalWrite(DIRA, dirA);
digitalWrite(DIRB, dirB);
analogWrite(PWMA, constrain(speedA, 0, 255));
analogWrite(PWMB, constrain(speedB, 0, 255));
}
// Handle obstacle avoidance
void avoidObstacle() {
float distance = getDistance();
if (distance < DISTANCE_THRESHOLD) {
Serial.println("Obstacle detected! Avoiding...");
unsigned long startTime = millis();
// Reverse
while (millis() - startTime < 500) {
controlMotor(MOTOR_SPEED, MOTOR_SPEED, LOW, LOW);
}
// Check distances on the left and right
float leftDistance = 0, rightDistance = 0;
// Simulate measuring with a rotating ultrasonic sensor
leftDistance = getDistance(); // Measure distance on the left
rightDistance = getDistance(); // Measure distance on the right
// Decide to turn left or right based on distances
if (leftDistance > rightDistance) {
Serial.println("Turning left to avoid obstacle.");
startTime = millis();
while (millis() - startTime < TURN_INTERVAL) {
controlMotor(MOTOR_SPEED, MOTOR_SPEED, LOW, HIGH);
}
} else {
Serial.println("Turning right to avoid obstacle.");
startTime = millis();
while (millis() - startTime < TURN_INTERVAL) {
controlMotor(MOTOR_SPEED, MOTOR_SPEED, HIGH, LOW);
}
}
// Continue moving forward
Serial.println("Continuing forward.");
controlMotor(MOTOR_SPEED, MOTOR_SPEED, HIGH, HIGH);
}
}
// Line-following algorithm using PID
void followLine() {
int sensorLeft = digitalRead(IR_LEFT);
int sensorRight = digitalRead(IR_RIGHT);
// Calculate error
int error = (sensorLeft == LOW ? -1 : 0) + (sensorRight == LOW ? 1 : 0);
// Handle line loss
if (sensorLeft == HIGH && sensorRight == HIGH) {
integral = 0; // Reset integral
controlMotor(MOTOR_SPEED / 2, MOTOR_SPEED, HIGH, LOW); // Rotate to find the line
delay(300);
return;
}
// Calculate PID
integral = constrain(integral + error, -MAX_INTEGRAL, MAX_INTEGRAL); // Limit integral value
float derivative = error - previousError;
int correction = (K_p * error) + (K_i * integral) + (K_d * derivative);
// Adjust motor speeds
int speedA = MOTOR_SPEED + correction;
int speedB = MOTOR_SPEED - correction;
controlMotor(speedA, speedB, HIGH, HIGH);
previousError = error;
// Debug information
Serial.print("Error: ");
Serial.print(error);
Serial.print(", Correction: ");
Serial.print(correction);
Serial.print(", Speed A: ");
Serial.print(speedA);
Serial.print(", Speed B: ");
Serial.println(speedB);
}
void setup() {
// Configure motor pins
pinMode(PWMA, OUTPUT);
pinMode(PWMB, OUTPUT);
pinMode(DIRA, OUTPUT);
pinMode(DIRB, OUTPUT);
// Configure sensor pins
pinMode(IR_LEFT, INPUT);
pinMode(IR_RIGHT, INPUT);
pinMode(CDS_LEFT_2_PIN, INPUT);
pinMode(CDS_RIGHT_2_PIN, INPUT);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
// Initialize Serial communication
Serial.begin(9600);
}
void loop() {
followLine(); // Line following
avoidObstacle(); // Obstacle avoidance
}
Background: For people starting microcontrollers (arduino esp32 etc) and small computers (Raspberry pi, Jetson Nano), you quickly learn after a while that you don’t really need the whole pcb when making only certain functionalities. You can prototype a smaller board with just the components you need (and of course the proper connections).
With machine learning, say Computer Vision, is it possible to strip down a computer down to bare necessities? what I want to know is… just like you can wire some LED with a timer IC for certain behavior(instead of coding it with an arduino) Can ML be done with just a certain circuit? (imagine a circuit board that only does computer vision and nothing else) —— I’m guessing it would still require a place for memory etc but in more detail, how can this be achieved?
Hi,
I'm using a Teensy 4.0 with the BNO085 sensor (Adafruit 4754). I need to read quaternions, angular velocities, and linear accelerations. I'm wondering which library would be the best for handling this sensor. Do you have any experience or recommendations for the most reliable option?
Thanks in advance!
I want keep The LED on till the button is pressed again
Hi fellow aquarium lovers and tech enthusiasts!
If you’ve ever wanted a smarter way to monitor your aquarium’s water parameters, I’d like to share a project I’ve been working on that might interest you. I’m both an aquarium hobbyist and a software engineer, and I wanted to create something that makes tracking water quality easy and customizable.
For this I've developed a DIY-friendly API for monitoring aquarium water parameters like pH, temperature, and more using Arduino.
Here’s how it works:
I started this project to better understand my own aquarium’s ecosystem, and it’s been a game-changer. Instead of manually checking water parameters, the system tracks everything automatically. It’s perfect for troubleshooting and maintaining a stable environment for your fish.
The great thing is, you can adapt this to any type of setup—freshwater, saltwater, even outdoor ponds. If you’re into tinkering with Arduino and love aquariums, this could be a fun weekend project.
The overall project is Open-Source under https://github.com/kesslermatics/Aquaware and has its own website https://aquaware.cloud/ with its own documentation for an easy beginning.
You can instantly use this API for free with basic features for all water parameters you have :D.
Feel free to ask me anything.
Cheers,
Robert
I have an Arduino pro micro that isn't taking my code, it come up with this error
This is the code
#include <Keyboard.h>
// Define row and column pins
const int rowPins[3] = {2, 3, 4}; // Rows connected to pins D2, D3, D4
const int colPins[3] = {5, 6, 7}; // Columns connected to pins D5, D6, D7
// Define the key bindings for each button in the matrix
const char keyBindings[3][3] = {
{'a', 'b', 'c'},
{'d', 'e', 'f'},
{'g', 'h', 'i'}
};
// State tracking for each key to prevent repeats
bool keyPressed[3][3] = {false};
void setup() {
Keyboard.begin();
// Set up row pins as INPUT_PULLUP
for (int i = 0; i < 3; i++) {
pinMode(rowPins[i], INPUT_PULLUP);
}
// Set up column pins as OUTPUT and start them HIGH
for (int i = 0; i < 3; i++) {
pinMode(colPins[i], OUTPUT);
digitalWrite(colPins[i], HIGH);
}
}
void loop() {
for (int col = 0; col < 3; col++) {
// Set current column to LOW
digitalWrite(colPins[col], LOW);
// Check each row
for (int row = 0; row < 3; row++) {
if (digitalRead(rowPins[row]) == LOW) {
if (!keyPressed[row][col]) {
// Key just pressed
Keyboard.press(keyBindings[row][col]);
keyPressed[row][col] = true;
}
} else {
if (keyPressed[row][col]) {
// Key just released
Keyboard.release(keyBindings[row][col]);
keyPressed[row][col] = false;
}
}
}
// Set the column back to HIGH
digitalWrite(colPins[col], HIGH);
}
}
Hi!
I am planning to start a project of making an air quality sensor by myself, and while this is a quite popular and well-discovered topic in the Arduino community, and I have done my research, I would like an approval that I chose the right hardware before I invest and order everything.
I would like to integrate the sensor to my home network, uploading the data via http requests to my server and saving it there, therefore I need an Arduino with a built-in wifi module.
I would like to have 4 sensors, namely: -BME280 temp, humidity and pressure sensor -PMS7003 for pm2.5 dust sensor -MH-Z19B for CO2 detection -SGP41-D-R4 for VOC and NOx detection
I have found extensive data an all sensors being compatible with the Arduinos one by one, having libraries for the code and guides for the hardware connections. But as to using all of them together on one Arduino, I only found guides from those who made it possible using custom printed boards, not explaining it in very much detail.
I am not totally lost in the topic (chemical engineer), but not really an expert in the field either. I would like some advice that these 4 sensors will work with something like an Arduino UNO R4 Wifi. Will I need anything else other than the listed hardwares, connecting cables and breadboard?
Any other advice or help is appreciated!
Hey I bought this Attiny85 chip from eBay And i want to download scripts to it but my computer can’t find its not showing up as a usb I did download the digit park drivers And it’s still not working Someone said to download the boot loader connected with an Arduino Uno??? But i don’t know where to start can someone explain to me how to make it work thx
I got an old alarm clock display from a broken alarm clock. I know the display works, and I'd like to use it to create a new clock with it via a microcontroller. However, I'm pretty new to all of this, so if possible, I'd really appreciate help in figuring out what all the pins do.
EDIT: Picture of it is in the comments!! Idk how to use Reddit...
Recently, I've been trying to configure and read configuration data from HC-05 modules. I had one module with a baseplate and a button for turning on AT mode, and with it, I could use the Arduino board to send config commands (the module responded, and everything was fine).
The other module doesn't have a button for turning on AT mode, so I've soldered an extra cable to the KEY pin and plugged it into the VCC to set it to a high state, but it didn't work. I can't turn on AT mode, and the same issue occurs with the module without the baseplate.
Do you have any ideas why it didn't work or what I might be doing wrong?
We've been using the Due for several years in a production machines without any issues. We're now looking to upgrade to the Giga R1. We sell these machines around the world and don't want any surprises.
I would like to set up a long strip of individually addressable LEDs inside my apartment along the edge of the ceiling.
I'm wondering about the best way to do this without a significant drop in voltage from one end to the other. Is there a particular style of strip that's best for this? Do I just need to power multiple smaller strips?
If anyone could give recommendations, it would be very helpful.
So, this is a hall effect potentiometer. I am using this device to fabricate some instruments for a weather station. it needs ground 5v, and output connections. The only reason I am wary of just directly soldering wires to it is that these pins are precisely machined, gold plated connectors and the sensor was very expensive (for an arduino device). It is also supposed to be very sensitive and precise, so I worry some about heat from soldering. This is not a resistive regular potentiometer; it uses hall effect sensors to output a voltage rather than a resistive strip.
As shown in the video, when the Arduino is plugged in it pops up with that notification and on the software I want to use for the boot loader it does not show in the com ports. How do I fix this?
Edit:
Thank you to everyone for pointing me in the right direction and providing such helpful suggestions! I’ll start by focusing on understanding the signals and how the control panel interacts with the roaster. Once I’ve gathered more information and have a clearer picture, I’ll come back with updates and any new questions. I really appreciate all the guidance so far!
Hi everyone,
I have this new hobby project, but I’m brand new to electronics, so I’d really appreciate any guidance! I’m working on controlling the temperature and fan speed of a coffee roaster using an Arduino UNO R3 connected to my PC. I've attached some pictures of the roaster's control panel, PCB, and wiring for reference.
The roaster has a 6-pin female cable (AWM 2469 VW-1) that connects from the control panel to the PCB. The main PCB is labeled MA-M102P-1. My goal is to intercept this connection to control the temperature and fan speed directly from an Arduino, but I’m still figuring out the best way to approach it.
Pictures: https://imgur.com/a/11ewko4
Again, I’m really new to electronics, so any insights or resources you could share would be incredibly helpful. Thanks in advance!
I've got TENSTAR ROBOT 1.3" screen from aliexpress: https://aliexpress.com/item/1005006997755041.html
It should support I2C protocol. I'm connecting it to a NodeMCU with esp8266 that I've got.
I can't find a way to display anything on that screen, it stays black no matter what I try.
Does anyone have the same screen?
Wire.begin(D2, D1);
With the above setup the simple "scanner" is somehow able to communicate with the module and I'm getting the address from the scanning process - 0x3D.
Even knowing all of these details I can't make it work with any library.
I tried Adafruit SH110X and u8g2 so far.
Any suggestions what I can do next? Maybe the screen is just broken but what should I do to verify it a bit better?
I uploaded an HID program and stared to disconect from my computer I tried to reset it but it doesn't work.How can i fix it?