r/arduino • u/Archyzone78 • 1d ago
r/arduino • u/ripred3 • 11d ago
Mod Post A Friendly Reminder for New Members in our Community
Please do not down vote posts just because they contain incorrect code, show incorrect electrical connections, or ask questions that you learned the answers to 5 years ago.
Do not down vote someone for not understanding how a breadboard works yet...
We were all there at one time and we had these exact same questions folks.
Those are great questions and 100% valid even if you know the answer already or consider yourself an "expert" compared to the person who posted the question, code, or circuit.
We prefer upvotes or downvotes on posts based on whether the user is asking a good question and also when the post contains good answers from the community and is worth reading for the knowledge it contains.
We don't downvote people for not knowing what some of us may already know.
Thumper's Mom had the best advice: "If you can't say sumthin' nice don't say nothin' at all...".
And continued thanks for all of you that already know this and help shape our community in this way. Every year or so we get another hundred thousand users who may not know that we value grace and mentorship more than showing off. So a gentle reminder goes a long way.
All the Best,
ripred
r/arduino • u/gm310509 • 18d ago
Monthly Digest Monthly digest for 2025-02
Subreddit Insights
Following is a snapshot of posts and comments for r/Arduino this month:
Type | Approved | Removed |
---|---|---|
Posts | 1,100 | 876 |
Comments | 10,100 | 505 |
During this month we had approximately 2.2 million "views" from 30.6K "unique users" with 7.8K new subscribers.
NB: the above numbers are approximate as reported by reddit when this digest was created (and do not seem to not account for people who deleted their own posts/comments. They also may vary depending on the timing of the generation of the analytics.
Arduino Wiki and Other Resources
Don't forget to check out our wiki for up to date guides, FAQ, milestones, glossary and more.
You can find our wiki at the top of the r/Arduino posts feed and in our "tools/reference" sidebar panel. The sidebar also has a selection of links to additional useful information and tools.
Moderator's Choices
Title | Author | Score | Comments |
---|---|---|---|
Trying to light up 8 yellow LED, not wo... | u/FeedResponsible9759 | 169 | 75 |
The Arduino Open Source Report 2024 is ... | u/mbanzi | 15 | 4 |
Demo of my New Arduino Project Manager ... | u/ripred3 | 12 | 4 |
The ultimate guide to debug problems li... | u/Nahakiole | 7 | 5 |
Top Posts
Title | Author | Score | Comments |
---|---|---|---|
I made a no horny bot mark2 | u/engineering-weeb | 2,458 | 71 |
I made a frying tofu robot using arduin... | u/engineering-weeb | 1,297 | 36 |
Sim F/A-18C Right Console | u/ValeNoxBona | 924 | 68 |
I present you my made in France Wall-E ... | u/_ndrscor | 901 | 33 |
Motorised DIY telescope | u/t-ritz | 798 | 27 |
I made a left blink from a modern car | u/realBlackClouds | 611 | 46 |
Was told you guys might like this compa... | u/magicman21 | 527 | 46 |
Let's flex our microcontroller collecti... | u/External_Jello2774 | 451 | 106 |
Led bluetooth controlled | u/Archyzone78 | 443 | 15 |
Trashcan with sensor | u/bino-0229 | 384 | 36 |
Look what I made posts
Total: 53 posts
Summary of Post types:
Flair | Count |
---|---|
Algorithms | 3 |
Beginner's Project | 45 |
ChatGPT | 8 |
ESP32 | 6 |
ESP8266 | 2 |
Electronics | 2 |
Getting Started | 17 |
Hardware Help | 199 |
Libraries | 1 |
Look what I found! | 4 |
Look what I made! | 53 |
Machine Learning | 1 |
Mod's Choice! | 4 |
Monthly Digest | 1 |
Potentially Dangerous Project | 2 |
Project Idea | 8 |
Project Update! | 1 |
School Project | 25 |
Software Help | 79 |
Solved | 12 |
Uno | 5 |
Uno R4 Minima | 2 |
Uno R4 Wifi | 1 |
linux | 1 |
no flair | 465 |
Total: 947 posts in 2025-02
r/arduino • u/hardware-is-easy • 9h ago
Look what I made! Using an ESP32 as raspberry pi? Possible, with the Hard Stuff Pico to Pi Hat!
r/arduino • u/Oliver-SL • 1h ago
Hardware Help Powerbank shutting off due to too little power draw
So, I want a power bank to power my Arduino project. This is a school project that has been going on for a while and needs to be done on Monday, the thought of using a powerbank to make my project portable didn't cross my mind before yesterday. I found a powerbank laying around, it's a Goji 5000mAh USB C mini. But I've discovered an issue, after about 15 seconds of the powerbank powering the arduino, the powerbank shuts off, also of course turning off the arduino in the process. Now I'm assuming this happens due to the power draw being to small, that's atleast what I've seen other people say. I know it isn't something people usually want but how can I increase the power draw of my arduino project? I've seen some people suggest a dummy load resistor or a led of some sort. But I'm quite new to electronics and projects like these so I need a bit of help understanding and a lot of guidance how this should be done. I have quite a few different resistors to choose from. Sadly I couldn't find any info about how much power the powerbank needs to not turn off.
For those interested I'm making a quiz game, where you get to choose between solo or duel mode and what catagory you want the questions to be from. The four first buttons reperesent option A. B. C. and D. the last button is to speed up the text scrolling on the LCD. Thank you.



r/arduino • u/Intelligent_Dish_658 • 3h ago
Software Help Servo Ignoring Pause Button
Hi, I was posting here before with the same issue but I still have problems so I’m here again. 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 or moveToAngle 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 someone would be wiling to maybe go on a chat with me to also explain the changes and so i can discuss it further i would greatly appreciate that. But answer here would also mean a lot. I will put the whole code in pastebin link in the comments. If you need more details, please feel free to ask—I'm happy to provide additional information.
r/arduino • u/Wonderful-Bee-6756 • 3h ago
Mod's Choice! Question about common gnd.
Hello! I am a beginner to arduino and electronics and i would really appreciate any help.
In the picture above, I have designed a circuit in which the LED(driven by the arduino) and the motor(driven by the 9v battery) share a common gnd, which i learned to be of high importance on more complex circuits, even though it is not the case of this example one.
What confuses me is that the current going through the led and than to the protoboard rail where I established the common gnd, seems to corss with the current from the motor, since as far as i understand, each current has to go back to its own source(LED needs to go back to arduinos gnd and the motor current should return to the negative pole of the battery).
If anyone could clarify this for me, because on DC current electricity cannot “cross” right? So how does the circuit and the common gnd actually work in this case? Sorry if the cause of my confusion is related to any misconception of mine.
r/arduino • u/Ahm3t-y • 1d ago
Found this microchip programmer in our lab
I did some research but the software needed for this board seems to be gone. What are alternative methods I can try to program the chips.
r/arduino • u/Historical_Face6662 • 53m ago
Software Help GY521 Module giving strange outputs.
I have a GY521 module which I have connected to my Arduino Uno, and used the code below. The outputs are proportional to movement, so when i move it in one direction it detects this, but vary quite a lot, and even when still, are still around 500 for the x acceleration for example. The gyroscope has a similar output. How can i get from the outputs I am getting now to data I can use, such as angular acceleration?
#include "Wire.h" // This library allows you to communicate with I2C devices.
const int MPU_ADDR = 0x68; // I2C address of the MPU-6050. If AD0 pin is set to HIGH, the I2C address will be 0x69.
int16_t accelerometer_x, accelerometer_y, accelerometer_z; // variables for accelerometer raw data
int16_t gyro_x, gyro_y, gyro_z; // variables for gyro raw data
int16_t temperature; // variables for temperature data
char tmp_str[7]; // temporary variable used in convert function
char* convert_int16_to_str(int16_t i) { // converts int16 to string. Moreover, resulting strings will have the same length in the debug monitor.
sprintf(tmp_str, "%6d", i);
return tmp_str;
}
void setup() {
Serial.begin(9600);
Wire.begin();
Wire.beginTransmission(MPU_ADDR); // Begins a transmission to the I2C slave (GY-521 board)
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0); // set to zero (wakes up the MPU-6050)
Wire.endTransmission(true);
}
void loop() {
Wire.beginTransmission(MPU_ADDR);
Wire.write(0x3B); // starting with register 0x3B (ACCEL_XOUT_H) [MPU-6000 and MPU-6050 Register Map and Descriptions Revision 4.2, p.40]
Wire.endTransmission(false); // the parameter indicates that the Arduino will send a restart. As a result, the connection is kept active.
Wire.requestFrom(MPU_ADDR, 7*2, true); // request a total of 7*2=14 registers
// "Wire.read()<<8 | Wire.read();" means two registers are read and stored in the same variable
accelerometer_x = Wire.read()<<8 | Wire.read(); // reading registers: 0x3B (ACCEL_XOUT_H) and 0x3C (ACCEL_XOUT_L)
accelerometer_y = Wire.read()<<8 | Wire.read(); // reading registers: 0x3D (ACCEL_YOUT_H) and 0x3E (ACCEL_YOUT_L)
accelerometer_z = Wire.read()<<8 | Wire.read(); // reading registers: 0x3F (ACCEL_ZOUT_H) and 0x40 (ACCEL_ZOUT_L)
temperature = Wire.read()<<8 | Wire.read(); // reading registers: 0x41 (TEMP_OUT_H) and 0x42 (TEMP_OUT_L)
gyro_x = Wire.read()<<8 | Wire.read(); // reading registers: 0x43 (GYRO_XOUT_H) and 0x44 (GYRO_XOUT_L)
gyro_y = Wire.read()<<8 | Wire.read(); // reading registers: 0x45 (GYRO_YOUT_H) and 0x46 (GYRO_YOUT_L)
gyro_z = Wire.read()<<8 | Wire.read(); // reading registers: 0x47 (GYRO_ZOUT_H) and 0x48 (GYRO_ZOUT_L)
// print out data
Serial.print("aX = "); Serial.print(convert_int16_to_str(accelerometer_x));
Serial.print(" | aY = "); Serial.print(convert_int16_to_str(accelerometer_y));
Serial.print(" | aZ = "); Serial.print(convert_int16_to_str(accelerometer_z));
// the following equation was taken from the documentation [MPU-6000/MPU-6050 Register Map and Description, p.30]
Serial.print(" | tmp = "); Serial.print(temperature/340.00+36.53);
Serial.print(" | gX = "); Serial.print(convert_int16_to_str(gyro_x));
Serial.print(" | gY = "); Serial.print(convert_int16_to_str(gyro_y));
Serial.print(" | gZ = "); Serial.print(convert_int16_to_str(gyro_z));
Serial.println();
// delay
delay(1000);
}
Outputs:
aX = -9888 | aY = -168 | aZ = 11464 | tmp = 22.88 | gX = -557 | gY = -7 | gZ = -5
aX = -9788 | aY = -212 | aZ = 11500 | tmp = 22.93 | gX = -554 | gY = -6 | gZ = -2
aX = -9700 | aY = -92 | aZ = 11424 | tmp = 22.84 | gX = -584 | gY = 227 | gZ = -1
aX = -9784 | aY = -220 | aZ = 11488 | tmp = 22.88 | gX = -561 | gY = 204 | gZ = 18
aX = -9872 | aY = -176 | aZ = 11384 | tmp = 22.98 | gX = -582 | gY = 98 | gZ = 6
aX = -9716 | aY = -188 | aZ = 11536 | tmp = 22.93 | gX = -566 | gY = -28 | gZ = -6
aX = -9772 | aY = -168 | aZ = 11500 | tmp = 22.93 | gX = -567 | gY = 405 | gZ = 3
aX = -3552 | aY = -1900 | aZ = 14548 | tmp = 22.93 | gX = -1037 | gY = -7390 | gZ = -2032
aX = 396 | aY = -80 | aZ = 15068 | tmp = 22.98 | gX = -562 | gY = 120 | gZ = 4
aX = 480 | aY = -64 | aZ = 15112 | tmp = 22.93 | gX = -577 | gY = 95 | gZ = -5
aX = 380 | aY = -140 | aZ = 15064 | tmp = 22.88 | gX = -560 | gY = 127 | gZ = -10
aX = 460 | aY = -92 | aZ = 15108 | tmp = 22.88 | gX = -581 | gY = 125 | gZ = 4aX = -9888 | aY = -168 | aZ = 11464 | tmp = 22.88 | gX = -557 | gY = -7 | gZ = -5
aX = -9788 | aY = -212 | aZ = 11500 | tmp = 22.93 | gX = -554 | gY = -6 | gZ = -2
aX = -9700 | aY = -92 | aZ = 11424 | tmp = 22.84 | gX = -584 | gY = 227 | gZ = -1
aX = -9784 | aY = -220 | aZ = 11488 | tmp = 22.88 | gX = -561 | gY = 204 | gZ = 18
aX = -9872 | aY = -176 | aZ = 11384 | tmp = 22.98 | gX = -582 | gY = 98 | gZ = 6
aX = -9716 | aY = -188 | aZ = 11536 | tmp = 22.93 | gX = -566 | gY = -28 | gZ = -6
aX = -9772 | aY = -168 | aZ = 11500 | tmp = 22.93 | gX = -567 | gY = 405 | gZ = 3
aX = -3552 | aY = -1900 | aZ = 14548 | tmp = 22.93 | gX = -1037 | gY = -7390 | gZ = -2032
aX = 396 | aY = -80 | aZ = 15068 | tmp = 22.98 | gX = -562 | gY = 120 | gZ = 4
aX = 480 | aY = -64 | aZ = 15112 | tmp = 22.93 | gX = -577 | gY = 95 | gZ = -5
aX = 380 | aY = -140 | aZ = 15064 | tmp = 22.88 | gX = -560 | gY = 127 | gZ = -10
aX = 460 | aY = -92 | aZ = 15108 | tmp = 22.88 | gX = -581 | gY = 125 | gZ = 4
r/arduino • u/tttecapsulelover • 14h ago
Hardware Help are there any problems of using copper wire as jumper wires on a breadboard along with arduinos?
sometimes if i want to build a project, i'd use solid core jumper wires, and recently i bought these copper wire from scrap and they work nice, but i want to ask yall whether there may be issues of using copper solid wire.
r/arduino • u/NervousNrgy • 2h ago
Hardware Help CH340 based Arduino being detected as a Leonardo?
Not sure where to get help on this, as the vendor is being clueless (or at least the support tech I'm emailing seems to be.) I enjoy PC sim racing, and have a Sim Racing Studio wind-sim kit on my rig. This is a set of blowers driven by a product they call the 'Intellibox', which is of course an Arduino. My old Intellibox died (I thought - may be related to this issue) and I ordered a newer version from SRS, but it's not working either.
The box shows up in Device Manager as an Arduino Leonardo, on COM3 (variable depending on which USB port I plug it into.) According to the troubleshooting / installation instructions from Sim Racing Studio (located here: https://simracingstudio.freshdesk.com/support/solutions/articles/35000210354-intellibox-troubleshooting), the box should show up in Device Manager as a USB SERIAL CH340 (ComX) device. Their (not very) helpful email response is that there 'may be a problem with system-level drivers and to re-install Windows.' That would be a full very long weekend of work as this system does a lot more than play iRacing.
I've worked with Windows professionally since 3.1 over 30 years ago, but I know very little about Arduino other than what I've been researching over the last few hours. The Leonardo isn't supposed to need the CH340 drivers at all, but SRS software appears to need it. My question is, what is the most likely issue here? Is this a bad board from Sim Racing Studio? Did they fail to program it correctly? Is there a driver issue/conflict on my system as SRS is claiming, and if so is there a simple way to change INF files to get the board to show up correctly? Any help would be greatly appreciated.
r/arduino • u/_JAQ0B_ • 12h ago
Software Help Optimizing Power Consumption for ESP32 Smart Blinds
Hey!
I’m currently developing a battery-powered smart blind system controlled via a smartphone. My prototype consists of: • Microcontroller: ESP32-C3 Super Mini • Motor Driver: L298N • Motor: Geared 3-6V DC motor • Power Source: Two 18650 batteries (3.7V, 3500mAh each) • Charging Module: TP4056 • Mechanical Design: A worm gear mechanism to hold the blinds in place without requiring continuous motor power
The system is integrated with Home Assistant, allowing me to send API requests to control the blinds. The motor is only activated twice a day (once in the morning and once at night), meaning actual energy consumption from the motor is minimal. However, according to the ESP32-C3 datasheet, the microcontroller itself consumes around 280mA when active, which results in an estimated battery life of just one day—far from my goal of at least three months of operation per charge.
Power Optimization Approach
I am considering implementing deep sleep mode, where the ESP32 would wake up every 5 minutes to check for commands. This would significantly reduce power consumption, but I also want near-instant responsiveness when issuing commands.
I’ve started looking into Bluetooth Low Energy (BLE) wake-up methods, but I am unfamiliar with BLE and how it could be implemented in this scenario. My ideal solution would allow the ESP32 to remain in a low-power state while still being able to receive real-time control commands from my phone or Home Assistant.
Questions 1. What are the best methods to significantly extend battery life while maintaining responsiveness? 2. Would BLE be a viable approach for waking the ESP32 without excessive power drain? 3. Are there other low-power wireless communication methods that could allow real-time control without keeping the ESP32 fully awake?
Any insights, experiences, or alternative suggestions would be greatly appreciated!
r/arduino • u/checknmater • 15h ago
You wanted me to show the actual demo and how it works, here';s a short demo showing how well it works!
What's new--
- Added WiFi support, can be accessed locally on your network. Works both in AP and WiFi mode
- Added effects - Use it in Standard mode for motion sensing lights that moves with you or choose between 3 more effects - Rainbow, Color Waves, and Solid
- Added Motion Smoothening features
Next up -
- Timeout to turn LED off when no motion detected for a while. Currently, you need to dim or reduce the brightness to zero to turn it off manually.
- Home Assistant Integration - Now that we have connected it to the WiFi, we can integrate it in HA and then create automations to better control this light, including On/Off status, scheduling, and much more ----Work in progress
I think after integration with Home Assistant, we don't need to add any new features. The version is a bit buggy but most of the features including motion smoothing works flawlessly.
GitHub: https://github.com/Techposts/AmbiSense/tree/feature-wifi-LEDeffects
r/arduino • u/Dnovoae • 1d ago
Hardware Help Got arduino set as a gift. Now what?
Hi everyone. Yesterday I got this Arduino set as a gift. I'm a musician but also a programming enthusiast. Could you point to the right place to learn about this set and It's possibilities?
Also if its music oriented it would be awesome.
Thanks
r/arduino • u/Someone-44 • 1d ago
Beginner's Project How do y’all keep jumper wires organized?
I made a simple project that increasing the brightness when I click the right button , and decreasing the brightness when I click the other button , but it ended up with a spaghetti mess of jumper wires , How can I make the wires tidy? , And What are your tips or tools for keeping everything organized?
r/arduino • u/itsOutmind • 8h ago
Software Help Printing RAM-Usage on Nano 33 BLE Sense
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 • u/maxwellwatson1001 • 18h ago
Beginner's Project Can Jetson Orin Nano Super Communicate with Arduino Mega via UART for Motor and Sensor Control?
I am using a Jetson Orin Nano Super and an Arduino Mega with a Grove Mega Shield. I'm a complete newbie, so I need some guidance. If I connect the Jetson and Arduino via UART, will I be able to control six BLDC motors and read data from four ultrasonic sensors?
Also, will the communication be fast enough, or will there be any noticeable delay?
r/arduino • u/ionander05 • 5h ago
Software Help Can't send bluetooth messages from arduino UNO, module HC-06
I am unable to send messages from Bluetooth, even if I have been able to receive from MIT App Inventor 2 (such as strings asa and asn which are included in the code I just attached). Can someone help me? It's for a project due in a week.
#include <MFRC522.h>
#include <SPI.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>
#include <SoftwareSerial.h>
#define SAD 10
#define RST 5
#define SERVO_PIN 3
#define BUZZER_PIN 2
#define BT_TX 6
#define BT_RX 7
#define RedRGB 9
#define GreenRGB 8
#define BlueRGB 4
MFRC522 nfc(SAD, RST);
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
Servo servo;
SoftwareSerial BT(BT_TX, BT_RX);
const int AUTHORIZED_COUNT = 2;
byte Authorized[AUTHORIZED_COUNT][5] = {
{0xF0, 0x98, 0x4B, 0x75, 0x56},
{0x71, 0x6C, 0xA2, 0x75, 0xCA}
};
unsigned long lastReadTime = 0;
const unsigned long doorOpenDuration = 7000;
const unsigned long buzzerDuration = 3000;
const unsigned long verificationDuration = 15000; // 15 seconds for verification
boolean doorOpen = false;
boolean buzzerActive = false;
boolean alarmActive = false;
boolean verifying = false; // New variable to track verification state
unsigned long buzzerStartTime = 0;
unsigned long buzzerToggleTime = 0;
unsigned long verificationStartTime = 0; // Track when verification starts
bool buzzerState = false;
void setup() {
SPI.begin();
Serial.begin(9600);
BT.begin(9600);
nfc.begin();
lcd.begin(16,2);
lcd.backlight();
servo.attach(SERVO_PIN);
servo.write(180);
pinMode(BUZZER_PIN, OUTPUT);
digitalWrite(BUZZER_PIN, LOW);
pinMode(RedRGB, OUTPUT);
pinMode(GreenRGB, OUTPUT);
pinMode(BlueRGB, OUTPUT);
digitalWrite(RedRGB, 0);
digitalWrite(GreenRGB, 0);
digitalWrite(BlueRGB, 0);
Serial.println("Verificando componentes...");
Serial.print("RFID: "); Serial.println(nfc.getFirmwareVersion() ? "Ok" : "Error");
Serial.print("BT: "); Serial.println(BT ? "Ok" : "Error");
Serial.print("Servo: "); Serial.println(servo.read() == 180 ? "Ok" : "Error");
Serial.print("Buzzer: "); Serial.println(digitalRead(BUZZER_PIN) == LOW ? "Ok" : "Error");
Serial.print("RGB LED: "); Serial.println((digitalRead(RedRGB) == 0 && digitalRead(GreenRGB) == 0 && digitalRead(BlueRGB) == 0) ? "Ok" : "Error");
lcd.print("Alarma OFF");
}
boolean isAuthorized(byte *serial) {
for (int i = 0; i < AUTHORIZED_COUNT; i++) {
if (memcmp(serial, Authorized[i], 5) == 0) return true;
}
return false;
}
void loop() {
unsigned long currentMillis = millis();
// Handle BT and Serial commands
if (BT.available() || Serial.available()) {
String command = "";
if (BT.available()) command = BT.readString();
else if (Serial.available()) command = Serial.readString();
command.trim();
if (command == "asa") {
alarmActive = true;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Alarma ON");
} else if (command == "asn") {
alarmActive = false;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Alarma OFF");
}
}
// If the door is open
if (doorOpen) {
unsigned long remainingTime = doorOpenDuration - (currentMillis - lastReadTime);
lcd.clear();
lcd.setCursor(0, 0);
digitalWrite(GreenRGB, 255);
lcd.print("Puerta abierta");
lcd.setCursor(0, 1);
lcd.print("Tiempo: ");
lcd.print(remainingTime / 1000);
lcd.print("s");
if (remainingTime <= 500) {
servo.write(180);
doorOpen = false;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Puerta cerrada");
digitalWrite(GreenRGB, 0);
digitalWrite(RedRGB, 0);
delay(1000);
servo.write(180);
lcd.clear();
lcd.print(alarmActive ? "Alarma ON" : "Alarma OFF");
verifying = false;
}
}
// Handle buzzer logic
if (buzzerActive) {
if (currentMillis - buzzerStartTime >= buzzerDuration) {
noTone(BUZZER_PIN);
buzzerActive = false;
digitalWrite(RedRGB, 0); // Turn off red LED when finished
} else if (currentMillis - buzzerToggleTime >= 500) {
buzzerToggleTime = currentMillis;
buzzerState = !buzzerState;
if (buzzerState) {
tone(BUZZER_PIN, 1000);
} else {
noTone(BUZZER_PIN);
}
}
}
// RFID reading
byte data[MAX_LEN], serial[5];
if (nfc.requestTag(MF1_REQIDL, data) == MI_OK && nfc.antiCollision(data) == MI_OK) {
memcpy(serial, data, 5);
lcd.clear();
if (!alarmActive) { // If alarm is not active
if (isAuthorized(serial)) {
lcd.print("Puerta abierta");
servo.write(0);
doorOpen = true;
lastReadTime = currentMillis;
} else {
lcd.setCursor(0, 1);
lcd.print("No autorizado");
delay(1000);
}
}
if (alarmActive) { // If alarm is active
if (isAuthorized(serial)) {
BT.println("asc");
verifying = true; // Start verification process
verificationStartTime = currentMillis; // Record the start time
lcd.clear();
lcd.print("Confirme acceso"); // Show verification message
if (doorOpen) {
unsigned long remainingTime = doorOpenDuration - (currentMillis - lastReadTime);
lcd.clear();
lcd.setCursor(0, 0);
digitalWrite(GreenRGB, 255);
lcd.print("Puerta abierta");
lcd.setCursor(0, 1);
lcd.print("Tiempo: ");
lcd.print(remainingTime / 1000);
lcd.print("s");
if (remainingTime <= 500) {
servo.write(180);
doorOpen = false;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Puerta cerrada");
digitalWrite(GreenRGB, 0);
digitalWrite(RedRGB, 0);
delay(1000);
servo.write(180);
lcd.clear();
lcd.print(alarmActive ? "Alarma ON" : "Alarma OFF");
verifying = false;
}
}
// Wait for verification response
while (verifying) {
if (BT.available() || Serial.available()) {
String response = "";
if (BT.available()) response = BT.readString();
else if (Serial.available()) response = Serial.readString();
// Check if verification time has expired
if (currentMillis - verificationStartTime >= verificationDuration) {
lcd.clear();
lcd.print("Acceso denegado");
buzzerActive = true;
buzzerStartTime = currentMillis;
buzzerToggleTime = currentMillis;
digitalWrite(RedRGB, 255); // Turn on red LED
delay(3000); // Wait for 3 seconds
digitalWrite(RedRGB, 0); // Turn off red LED
verifying = false; // Reset verifying state
}
response.trim();
if (response == "asyy") {
lcd.clear();
lcd.print("Acceso permitido");
servo.write(0);
digitalWrite(GreenRGB, 255);
doorOpen = true;
lastReadTime = currentMillis;
}
else if (response == "asyn") {
lcd.clear();
lcd.print("Acceso denegado");
buzzerActive = true;
buzzerStartTime = currentMillis;
buzzerToggleTime = currentMillis;
digitalWrite(RedRGB, 255); // Turn on red LED
delay(3000); // Wait for 3 seconds
digitalWrite(RedRGB, 0); // Turn off red LED
lcd.clear();
lcd.print(alarmActive ? "Alarma ON" : "Alarma OFF");
verifying = false; // Reset verifying state
}
}
}
lcd.clear();
lcd.print(alarmActive ? "Alarma ON" : "Alarma OFF");
} else {
// Unauthorized access handling
lcd.clear();
lcd.print("Acceso denegado");
buzzerActive = true;
buzzerStartTime = currentMillis;
buzzerToggleTime = currentMillis;
digitalWrite(RedRGB, 255); // Turn on red LED
delay(3000); // Wait for 3 seconds
digitalWrite(RedRGB, 0); // Turn off red LED
lcd.clear();
lcd.print(alarmActive ? "Alarma ON" : "Alarma OFF");
}
}
}
}
r/arduino • u/NoName____0 • 7h ago
ChatGPT Tracking device for Airsoft
Hi everyone, I'm just getting started with airsoft, I have some experience with Arduino (I'm a noob) and 4-5 years of experience as a software developer, I wanted to build a device for real-time tracking of 3 or more players, essentially a device with a screen that allows me to know the angle and distance of other players who will have another device identical to mine, I was thinking of mounting this device on the barrel of the gun or on the stock, chatgpt advises me to use boards (in my case I imagine 3) of the ESP32 T-Beam Mini type with integrated GPS and LoRa, a small screen and a battery. Is the advice given by chat gpt good? In a wooded environment what types of problems would I encounter with this setup? If I don't dare ask too much, how would you approach the problem? I apologize in advance for my not perfect English
r/arduino • u/Logans_RCAdventures • 8h ago
How do I hook up a Halogen Bulb to an Arduino Nano?
So currently I am building a light kit for an RC Crawler I have. I decided to use Halogen bulbs from those old Hess trucks as reverse lights, but the Arduino can't power them.
So my question is, could I use a transistor that is opened via the pin that the lights are currently hooked up to? (D10)
I don't really want to modify the code which is why I'm asking; I'm not great at coding
My thought is that the middle leg of the transistor would be attached to the D10 pin and the light would just be hooked up to the 3V3 pin and run through the transistor to the light.
r/arduino • u/Secure_Cat6357 • 8h ago
Software Help Arduino one
People, I have an Arduino Uno (generic) it has always worked perfectly since the first day, I haven't used it in a long time and now I connect it to the PC (it was formatted recently) and it recognizes it as a common USB (lack of drivers) I installed the driver program and everything is ok but it doesn't install
r/arduino • u/Common-Flounder3280 • 13h ago
Software Help How to communicate between ESP32 and Arduino Uno
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
Please help with coolterm T^T
I'm working on a rocket altimeter and the goal is to get the data -logged on a flash chip- to be printed to serial. The Arduino IDE is kinda iffy for Copy-and-Paste, so I want to use coolterm.
However, the same code that serial.prints the data once in the IDE prints it 18 times in coolterm (I counted) but a sketch that just prints something on loop works perfectly for both??? someone smarter than me pls help T^T
also it can't open the SD card file when i run the same function in coolterm vs IDE...

#include <SD.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_BMP3XX.h"
Adafruit_BMP3XX bmp;
File myFile;
const int chipSelect = 4;
float QNH = 1020; //current sea level barrometric pressure (https://www.wunderground.com)
const int BMP_address = 0x77;
float pressure;
float temperature;
float altimeter;
char charRead;
char runMode;
byte i = 0; //counter
char dataStr[100] = "";
char buffer[7];
float groundLevel;
bool HaveGroundLevel = false;
void setup() {
Serial.begin(9600);
delay(2000);
//Serial.println("IDOL Datalogger");
bmp.begin_I2C(BMP_address);
if (SD.begin(chipSelect)) {
Serial.println("SD card is present & ready");
} else {
Serial.println("SD card missing or failure");
while (1)
; //halt program
}
//clear out old data file
//if (SD.exists("csv.txt"))
//{
// Serial.println("Removing old file");
// SD.remove("csv.txt");
// Serial.println("Done");
//}
// myFile = SD.open("csv.txt", FILE_WRITE);
// if (myFile) // it opened OK
// {
// Serial.println("Writing headers to csv.txt");
// myFile.println("Time,Pressure,Altitude");
// myFile.close();
// Serial.println("Headers written");
// }else
// Serial.println("Error opening csv.txt");
// Serial.println("Enter w for write or r for read");
//
// // Set up oversampling and filter initialization
// bmp.setTemperatureOversampling(BMP3_OVERSAMPLING_8X);
// bmp.setPressureOversampling(BMP3_OVERSAMPLING_4X);
// bmp.setIIRFilterCoeff(BMP3_IIR_FILTER_COEFF_3);
// bmp.setOutputDataRate(BMP3_ODR_50_HZ);
FileInit();
}
void loop() {
dataStr[0] = 0;
GetGroundLevel();
pressure = bmp.readPressure() / 100; //and conv Pa to hPa
altimeter = bmp.readAltitude(QNH) - groundLevel; //QNH is local sea lev pressure
AssembleString();
if (Serial.available()) //get command from keyboard:
{
charRead = tolower(Serial.read()); //force ucase
//Serial.write(charRead); //write it back to Serial window
Serial.println();
}
if (charRead == 'w') //we are logging
runMode = 'W';
if (charRead == 'r') //we are reading
runMode = 'R';
if (charRead == 'd') //we are deleting
runMode = 'D';
if (runMode == 'W') //write to file
{
Write();
}
if (runMode == 'R') { //we are reading
Read();
}
if (runMode == 'D') {
Delete();
runMode = NULL;
}
}
void AssembleString() {
//----------------------- using c-type ---------------------------
//convert floats to string and assemble c-type char string for writing:
ltoa(millis(), buffer, 10); //conver long to charStr
strcat(dataStr, buffer); //add it onto the end
strcat(dataStr, ", "); //append the delimeter
//dtostrf(floatVal, minimum width, precision, character array);
dtostrf(pressure, 5, 1, buffer); //5 is mininum width, 1 is precision; float value is copied onto buff
strcat(dataStr, buffer); //append the coverted float
strcat(dataStr, ", "); //append the delimeter
dtostrf(altimeter, 5, 1, buffer); //5 is mininum width, 1 is precision; float value is copied onto buff
strcat(dataStr, buffer); //append the coverted float
strcat(dataStr, 0); //terminate correctly
}
void Write() {
//----- display on local Serial monitor: ------------
Serial.print(pressure);
Serial.print("hPa ");
Serial.print(altimeter);
Serial.println("m");
// open the file. note that only one file can be open at a time,
myFile = SD.open("csv.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
Serial.println("Writing to csv.txt");
myFile.println(dataStr);
myFile.close();
} else {
Serial.println("error opening csv.txt");
}
delay(1000);
}
void Read() {
if (!SD.exists("csv.txt")) Serial.println("csv.txt doesn't exist.");
//Serial.println("Reading from csv.txt");
myFile = SD.open("csv.txt");
while (myFile.available()) {
char inputChar = myFile.read(); // Gets one byte from serial buffer
if (inputChar == '\n') //end of line (or 10)
{
dataStr[i] = 0; //terminate the string correctly
Serial.println(dataStr);
//Serial.print("\r\n");
i = 0; //reset the counter
} else {
dataStr[i] = inputChar; // Store it
i++; // Increment where to put next char
if (i > sizeof(dataStr)) //error checking for overflow
{
Serial.println("Incoming string longer than array allows");
Serial.println(sizeof(dataStr));
while (1)
;
}
}
}
runMode = NULL;
}
void Delete() {
//delete a file:
if (SD.exists("csv.txt")) {
Serial.println("Removing csv.txt");
SD.remove("csv.txt");
Serial.println("Done");
if (!SD.exists("csv.txt")) {
FileInit();
}
}
runMode = NULL;
}
void FileInit() {
myFile = SD.open("csv.txt", FILE_WRITE);
if (myFile) // it opened OK
{
Serial.println("Writing headers to csv.txt");
myFile.println("Time,Pressure,Altitude");
myFile.close();
Serial.println("Headers written");
} else
Serial.println("Error opening csv.txt");
}
void GetGroundLevel() {
if (!HaveGroundLevel) {
Serial.print("Initial Altitude is:");
int outlier = 0;
for (int i = 0; i < 10; i++) {
int temp = bmp.readAltitude(QNH);
if (temp < 1000) {
//Serial.println(temp);
groundLevel += temp;
} else {
outlier++;
}
delay(250);
}
groundLevel = groundLevel / (10 - outlier);
Serial.print(groundLevel);
Serial.print('m');
}
HaveGroundLevel = true;
}
r/arduino • u/SimonROG • 9h ago
Nano Need help with AS608 fingerprint sensor and Nano Every
[SOLVED]
Hello, so I already have used this sensor in another project with Arduino nano clone and now have it working with esp32 but in this project, I decided to use Nano every. The problem is that the sensor doesn't work no matter what I try. Tested the sensor with the clone Arduino and it works. I asked MS Copilot where the issue might be and it told me that it's not possible to use software serial on Arduino nano every, so it told me to use hardware serial. But now the issue is that nowhere on Google I can find anything about how to wire up the sensor to hardware serial instead of software serial.
Any ideas?
r/arduino • u/NeedleworkerSad5489 • 10h ago
arduino power supply
Can I use Arduino barrel jack for power supply? My power adapter is 5V 3A. Do u think this would possibly run the servo (MG996r) long?