/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
After sooo many different suggestions.. things STILL will not work.
I can NOT get these super-mini ESP32-S3 boards to compile.. ( I believe it happened once..somehow? random button clicking from many different threads/searches).. but even after the '(I believe)' upload.. it was still blinking the led..
And now after so many attempts. things will just NOT compile. Looking for some help on how to get this stupid Arduino IDE compliant to work with these boards.
Tried different UPLOAD speed/settings (was told this is not an issue after reading about it so many times?)
IDE has been acting very weird. Sometimes COM3, sometimes COM3 with jTAG.. and now COM3 ESP32 family device?
I am confused on where things are to even be installed/put?
Originally: user/documents/Arduino >
Sometimes: C:\program files (x86)\Arduino
So I am very unclear on WHAT is to be here.. and WHERE it is to be placed/run..etc.
Current:
Arduino IDE
Board: ESP32S3 Dev Module
Port: COM3 (ESP32 Family Device)
Currently (after so much messing around)
I open IDE, I hit UPLOAD: (it takes forever to 'compile')...
I am now seeing this error?
xtensa-esp32s3-elf-g++ does not exist?????
What am I missing here?
Thanks!!
Or can only the apc220 transmit and recieve to another apc220? And if so, what are good options for cheaper rf modules while having about the same range?
Hello! I'm doing a project for my girlfriends christmas present and im trying to use a DF mini player to play a song and a rotary encoder to change the volume and pause/play when needed. So far I have this code but the rotary encoder has trouble being consistent when changing the volume or just starts acting on its own. I have done separate code where i use it just by itself and it works fine but when i group it with the DF mini and the 0.98" tft screen on the arduino it seems to start having the issues again if anyone could help i would greatly appreciate it and happy holidays!
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <SoftwareSerial.h>
#include <DFRobotDFPlayerMini.h>
// OLED display settings
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// DFPlayer Mini settings
SoftwareSerial mySoftwareSerial(10, 11); // RX, TX pins for DFPlayer Mini
DFRobotDFPlayerMini myDFPlayer;
// Rotary encoder and button settings
const int encoderPinA = 2; // CLK pin for rotary encoder
const int encoderPinB = 3; // DT pin for rotary encoder
const int buttonPin = 4; // SW pin for push button
int volume = 5; // Start volume at 5
int lastEncoderStateA = LOW;
int lastEncoderStateB = LOW;
bool rotating = false;
bool lastButtonState = HIGH;
bool buttonPressed = false;
// Time tracking
unsigned long songDuration = 283000; // Song duration in ms (4:43 = 283000 ms)
unsigned long songStartTime = 0;
int elapsedSeconds = 0;
int elapsedMinutes = 0;
// Debounce settings
unsigned long lastDebounceTime = 0;
unsigned long debounceDelay = 10; // debounce time; increase if needed
void setup() {
// Serial communication
Serial.begin(9600);
mySoftwareSerial.begin(9600);
// Pin configurations
pinMode(encoderPinA, INPUT);
pinMode(encoderPinB, INPUT);
pinMode(buttonPin, INPUT_PULLUP);
// Initialize DFPlayer Mini
if (!myDFPlayer.begin(mySoftwareSerial)) {
Serial.println("DFPlayer Mini not detected!");
while (true);
}
Serial.println("DFPlayer Mini ready.");
myDFPlayer.volume(volume); // Set initial volume
myDFPlayer.play(1); // Play track 1
songStartTime = millis();
// Initialize OLED display
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x64
Serial.println(F("SSD1306 allocation failed"));
while (1);
}
display.clearDisplay();
display.display();
// Show the initial image
displayImage();
}
void loop() {
// Handle rotary encoder for volume control
handleEncoder();
// Handle play/pause button
handleButton();
// Update elapsed time
updateElapsedTime();
// Update OLED display
updateOLED();
}
void handleEncoder() {
// Read the current state of the encoder pins
int currentStateA = digitalRead(encoderPinA);
int currentStateB = digitalRead(encoderPinB);
// Check if the state of A has changed
if (currentStateA != lastEncoderStateA) {
unsigned long currentTime = millis();
if ((currentTime - lastDebounceTime) > debounceDelay) { // Check if debounce delay has passed
rotating = true;
// Determine the direction of rotation
if (currentStateB != currentStateA) {
volume++; // Clockwise, increase volume
} else {
volume--; // Counterclockwise, decrease volume
}
// Constrain volume between 0 and 30
volume = constrain(volume, 0, 30);
// Update volume on DFPlayer Mini
myDFPlayer.volume(volume);
Serial.print("Volume: ");
Serial.println(volume);
// Update the last debounce time
lastDebounceTime = currentTime;
}
}
// Update the last known state
lastEncoderStateA = currentStateA;
rotating = false;
}
void handleButton() {
bool currentButtonState = digitalRead(buttonPin);
if (currentButtonState == LOW && lastButtonState == HIGH) {
delay(50); // Debounce delay
buttonPressed = !buttonPressed;
if (buttonPressed) {
myDFPlayer.pause();
Serial.println("Paused");
} else {
myDFPlayer.start();
Serial.println("Playing");
songStartTime = millis() - ((elapsedMinutes * 60 + elapsedSeconds) * 1000); // Adjust start time
}
}
lastButtonState = currentButtonState;
}
void updateElapsedTime() {
if (!buttonPressed) { // Only update time if playing
unsigned long currentTime = millis();
unsigned long elapsedTime = currentTime - songStartTime;
elapsedMinutes = (elapsedTime / 1000) / 60;
elapsedSeconds = (elapsedTime / 1000) % 60;
}
}
void displayImage() {
// Replace this with the bitmap you want to display
const unsigned char PROGMEM myImage[] = {
// Example bitmap data
0xFF, 0x81, 0x81, 0x81, 0xFF, 0x00, 0x00, 0x00, // Top line
// Add more rows for a full 128x64 image
};
display.clearDisplay();
display.drawBitmap(0, 0, myImage, SCREEN_WIDTH, SCREEN_HEIGHT, SSD1306_WHITE);
display.display();
}
void updateOLED() {
display.clearDisplay(); // Clear the display
// Animated Sound Waves
if (!buttonPressed) { // Only animate when playing
for (int i = 0; i < 5; i++) {
int barHeight = random(5, 20); // Randomized heights
display.fillRect(10 + (i * 8), 20 - barHeight / 2, 6, barHeight, SSD1306_WHITE);
}
} else {
// Static sound bars when paused
for (int i = 0; i < 5; i++) {
display.fillRect(10 + (i * 8), 10, 6, 10, SSD1306_WHITE);
}
}
// Song Progress Bar
unsigned long elapsedTimeMs = (elapsedMinutes * 60 + elapsedSeconds) * 1000;
int progress = map(elapsedTimeMs, 0, songDuration, 0, SCREEN_WIDTH - 20);
display.drawRect(10, 40, SCREEN_WIDTH - 20, 5, SSD1306_WHITE); // Outline
display.fillRect(10, 40, progress, 5, SSD1306_WHITE); // Fill bar
// Song Title ("Space and Time")
display.setTextSize(1); // Smaller text size for title
display.setTextColor(SSD1306_WHITE);
int titleWidth = 6 * 14; // "Space and Time" has 14 characters, each 6 pixels wide
display.setCursor((SCREEN_WIDTH - titleWidth) / 2, 32); // Center the title horizontally above the progress bar
display.println(F("Space and Time")); // Song title
// Time Indicators
display.setCursor(10, 48);
display.print(formatTime(elapsedMinutes, elapsedSeconds)); // Elapsed time
display.setCursor(SCREEN_WIDTH - 35, 48);
display.println("4:43"); // Fixed song duration
// Volume Indicator
display.setCursor(0, 0);
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.print("Volume: ");
display.println(volume);
// Play/Pause Icon
if (buttonPressed) {
display.fillRect(60, 50, 4, 10, SSD1306_WHITE); // Pause bar 1
display.fillRect(68, 50, 4, 10, SSD1306_WHITE); // Pause bar 2
} else {
display.fillTriangle(60, 50, 60, 60, 70, 55, SSD1306_WHITE); // Play icon
}
display.display(); // Update the display
}
String formatTime(int minutes, int seconds) {
String timeString = String(minutes) + ":";
if (seconds < 10) timeString += "0"; // Add leading zero
timeString += String(seconds);
return timeString;
}
I know this channel is about Arduino but before implementing an Arduino in my project I needed some help.
I'm using DFPlayer Mini in my project but it doesn't always turn on when I turn on the switch and sometimes it turns off halfway through, how do I fix it?
I would like to know the value of the current when connecting a module to the 5V pin or an i/o pin without a resistor in between the board and the module.
To know the value of i, you need to divide V/R but I don't have a value for "R" because there is no resistor.
Could someone help me with this?
Thx in advance.
I ordered one of these boards due to its Wi-Fi and Bluetooth capabilities but I cannot seem to get it to work with Arduino IDE. I am fairly new to Arduino stuff in general but I was wondering if anyone knew anything about this and could help me out. Thank you.
Here is a link to the board that I bought:
https://www.amazon.com/gp/product/B0718T232Z/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1
These are the error messages I receive:
COM Port 1 ---
A fatal error occurred: Failed to connect to ESP32: No serial data received.
For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html
Failed uploading: uploading error: exit status 2
COM Port 6 ---
A fatal error occurred: Could not open COM6, the port doesn't exist
Failed uploading: uploading error: exit status 2
COM Port 7 ---
A serial exception error occurred: Write timeout
Note: This error originates from pySerial. It is likely not a problem with esptool, but with the hardware connection or drivers.
For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html
Failed uploading: uploading error: exit status 1
My arduino Uno is running the prev code i upload now when i'm trying to upload a new code it says done uploading but the prev code still running
Very much a beginner question.
I am working towards a setup that is pretty similar to a diagram I found on github:
Leave out the servo, add some more motors and 2 batteries and that's what I am going for
I would like to add some leds, however I doubt I can connect them to the batteries without adding resistance. 2 White ones and 4 red ones with the following specifications:
The battery pack should be around 5-7ish V as far as I am aware, which is the same as 2 white leds or 4 red leds added up, 5.6-7.2V and 6.2-9.2V (pure coincidence by the way).
Could I add them in 2 seperate loops, or will I need to add resistors to prevent the current from going far above 20mA per loop? If that is the case, where to the Sensor Shield should I add the, for a voltage that is in line?
I don't need them to interact with the arduino, always being on is fine. The brighter the better.
Thx :)
Hi, I'll start the EE Degree soon and I'd like to start getting hands on in very basics projects to get experience and be more familiar with the subfield of electronics and automatization since is the field that more interests me alongside with the telecommunications. So I wanted to ask what to build, where can I find some cool ideas to do, or maybe some YouTube channels that you recommend, some guides, etc.
Obviously I've searched info by my own but I'd like to read your recommendations for someone that is just starting in this world.
Ty!
Hi I have a STM32F373 are there any packages for arduino that supports it as the stmcore doesn't
Hello, I'm quite interrested in learning arduino for a long time but never had a project to work on until now.
I have a motorized wing on a project car.
Atm the DC motor is controlled via small boards/ relay / limit switch.
I could divide the project in different steps wich is good :
step 1 → (basicly same as is it is now) :
step 2 → One push switch + startup procedure :
Step 3 → Air brake/active aero (quite easy step actually, juste need to had another limit-switch)
step 4 → speed activated (Gps module?) :
I have pretty good wiring/basic electronics knowledge working on car, as well in IT Building computers... But Zero knowledge in coding and that is the part I'm a bit afraid of...
Do you think it is a good starting project?
I heard AI works pretty good writing code now, is that true?
Thanks for your advices.
I've recently got some SG90 servo motors. I only had a vague idea of how to use them, but I still wanted to explore this whole new area of mechanical systems and controlling devices.
After a bit of research, I've learnt that powering them from the VIN pin of my Atmega board is a really bad idea, as they will try to draw too much current. I have an Atmega board (I believe it's a clone of an Arduino Nano) powered by a USB charger, so it provides 5V on the VIN pin.
Will it work if:
Another question regarding the SG90: has anyone seen a version that comes with a differently sized servo arm? I've printed a few 3D models and it looks like the single-sided arm I received with the servo is larger and doesn't fit those models.
Any tips on where to buy a bunch of mounts for 9g servos in the UK? Or with cheapish shipping to UK. Can’t seem to find much online. I just want a simple cracked to keep it in place.
the module has a 8x8 LED matrix piloted by the MAX7219, i need it to make the whole matrix blink for test purposes.
When using the pin 7 as Chip Select (CS) everything works but when i change it to 12 the matrix won't do anything. Changinge the number on line 3 does not work and not even directly inserting 12 on pinMode and digitalWrite functions.
there is no external circuitry, only this module
//Clock=13,chip select=7, Data input=11
#include <SPI.h>
#define CS 7 //I wish to change this to 12 and have it work
#define DECODE_MODE 9
#define INTENSITY 10
#define SCAN_LIMIT 11
#define SHUTDOWN 12
#define DISPLAY_TEST 16
void setup() {
pinMode(CS,OUTPUT);
SPI.setBitOrder(MSBFIRST);
SPI.begin();
SendData(DISPLAY_TEST, 0x01);
delay(1000);
SendData(DISPLAY_TEST, 0x00);
SendData(DECODE_MODE, 0x00);
SendData(INTENSITY, 0xff);
SendData(SCAN_LIMIT, 0x0f);
SendData(SHUTDOWN, 0x01);
}
void loop() {
SendData(1,B11111111);
SendData(2,B11111111);
SendData(3,B11111111);
SendData(4,B11111111);
SendData(5,B11111111);
SendData(6,B11111111);
SendData(7,B11111111);
SendData(8,B11110111);
delay(1000);
SendData(1,B00000000);
SendData(2,B00000000);
SendData(3,B00000000);
SendData(4,B00000000);
SendData(5,B00000000);
SendData(6,B00000000);
SendData(7,B00000000);
SendData(8,B00000000);
delay(1000);
}
void SendData (uint8_t address, uint8_t value){
digitalWrite(CS,LOW);
SPI.transfer(address);
SPI.transfer(value);
digitalWrite(CS, HIGH);
}
I'm new to Arduino and electronics for the sake of our thesis. I cannot upload libraries into the cloud and thus my sketches cannot be verified. It shows this this whenever I upload.
Selected file is not a valid library: library does not contain a library.proprties file.
The file I am uploading is a zip file. Im basically lost at this point there is no guides in youtube or anything that could help me. Without this library, I don't know how to proceed and thus it is important I can upload this on the cloud.
For context, I am needing to upload a library for an ACS712 current sensor. I hope anyone could help me fine alternatives as my thesis deadline is fast approaching. Thanks!
Hi,
For a project I’m working on, I need to read two analog inputs simultaneously (or as close to simultaneously as possible) during a mechanical action that lasts between 2 to 10 seconds. I need to send this data to my PC for analysis using a Python script.
I don’t need real-time data transfer to the PC; I can store the readings in the microcontroller’s memory and send them in a single batch when the mechanical action is complete.
A 12-bit resolution is sufficient (although 16-bit will be nicer), and I’d prefer not to reduce it to 8-bit. I estimate that I need about 100–200 samples per second from each analog input, for a total of around 500 Hz across both inputs togheter.
My current setup includes a Raspberry Pi Pico and an ADS1015 chip. I’m reading the analog signals using the Adafruit library and sending the readings directly to the PC , via Serial.print.
The USB baud rate is set to 1M. Under these conditions, I’m getting about 30 samples per second from each analog channel (60 samples per second total), which is lower than my target rate.
I’d like to increase the sampling speed. Are there any modifications I can make to my existing setup to achieve a higher sampling rate? Or should I consider a different approach, such as using a dedicated DAQ device? At this point, I’d prefer not to use an oscilloscope due to the cost.
Edit: Could be that the Bottleneck is in the Python code ? How should i test it ?
Thank you.
I'm absolutely new to coding and Arduino and I made a simple car at a workshop my school organized. They uploaded the code for me at the workshop but there were some issues with wrong buttons triggering the wrong motion. I have the code and I'm trying to upload it again to try and fix the issues but this shows up when I do:
Sketch uses 1878 bytes (5%) of program storage space. Maximum is 32256 bytes.
Global variables use 188 bytes (9%) of dynamic memory, leaving 1860 bytes for local variables. Maximum is 2048 bytes.
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xd6
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xd6
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xd6
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xd6
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xd6
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xd6
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xd6
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xd6
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xd6
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xd6
Failed uploading: uploading error: exit status 1
This is the code:
char t;
const int m1= 2;
const int m2= 3;
const int m3= 4;
const int m4= 5;
const int enA= 9;
const int enB= 10;
void setup() {
Serial.begin (9600);
pinMode(m1, OUTPUT); //left motors forward
pinMode(m2, OUTPUT); //left motors reverse
pinMode(m3, OUTPUT); //right motors forward
pinMode(m4, OUTPUT); //right motors reverse
pinMode(enA, OUTPUT);
pinMode(enB, OUTPUT);
digitalWrite(m1, LOW);
digitalWrite(m2, LOW);
digitalWrite(m3, LOW);
digitalWrite(m4, LOW);
analogWrite(enA, 0);
analogWrite(enB, 0);
}
void forward(){
digitalWrite(m1, HIGH);
digitalWrite(m2, LOW);
digitalWrite(m3, HIGH);
digitalWrite(m4, LOW);
analogWrite(enA, 200);
analogWrite(enB, 200);
}
void backward(){
digitalWrite(m1, LOW);
digitalWrite(m2, HIGH);
digitalWrite(m3, LOW);
digitalWrite(m4, HIGH);
analogWrite(enA, 200);
analogWrite(enB, 200);
}
void left(){
digitalWrite(m1, HIGH);
digitalWrite(m2, LOW);
digitalWrite(m3, LOW);
digitalWrite(m4, HIGH);
analogWrite(enA, 200);
analogWrite(enB, 200);
}
void right(){
digitalWrite(m1, LOW);
digitalWrite(m2, HIGH);
digitalWrite(m3, HIGH);
digitalWrite(m4, LOW);
analogWrite(enA, 200);
analogWrite(enB, 200);
}
void stopp(){
digitalWrite(m1, LOW);
digitalWrite(m2, LOW);
digitalWrite(m3, LOW);
digitalWrite(m4, LOW);
analogWrite(enA, 0);
analogWrite(enB, 0);
}
void loop() {
if (Serial.available()) {
t = Serial.read();
Serial.println(t);
}
if (t== 'F'){
void forward();
}
if (t== 'B'){
void backward();
}
if (t== 'R'){
void right();
}
if (t== 'L'){
void left();
}
if (t== 'S'){
void stopp();
}
}
char t;
const int m1= 2;
const int m2= 3;
const int m3= 4;
const int m4= 5;
const int enA= 9;
const int enB= 10;
void setup() {
Serial.begin (9600);
pinMode(m1, OUTPUT); //left motors forward
pinMode(m2, OUTPUT); //left motors reverse
pinMode(m3, OUTPUT); //right motors forward
pinMode(m4, OUTPUT); //right motors reverse
pinMode(enA, OUTPUT);
pinMode(enB, OUTPUT);
digitalWrite(m1, LOW);
digitalWrite(m2, LOW);
digitalWrite(m3, LOW);
digitalWrite(m4, LOW);
analogWrite(enA, 0);
analogWrite(enB, 0);
}
void forward(){
digitalWrite(m1, HIGH);
digitalWrite(m2, LOW);
digitalWrite(m3, HIGH);
digitalWrite(m4, LOW);
analogWrite(enA, 200);
analogWrite(enB, 200);
}
void backward(){
digitalWrite(m1, LOW);
digitalWrite(m2, HIGH);
digitalWrite(m3, LOW);
digitalWrite(m4, HIGH);
analogWrite(enA, 200);
analogWrite(enB, 200);
}
void left(){
digitalWrite(m1, HIGH);
digitalWrite(m2, LOW);
digitalWrite(m3, LOW);
digitalWrite(m4, HIGH);
analogWrite(enA, 200);
analogWrite(enB, 200);
}
void right(){
digitalWrite(m1, LOW);
digitalWrite(m2, HIGH);
digitalWrite(m3, HIGH);
digitalWrite(m4, LOW);
analogWrite(enA, 200);
analogWrite(enB, 200);
}
void stopp(){
digitalWrite(m1, LOW);
digitalWrite(m2, LOW);
digitalWrite(m3, LOW);
digitalWrite(m4, LOW);
analogWrite(enA, 0);
analogWrite(enB, 0);
}
void loop() {
if (Serial.available()) {
t = Serial.read();
Serial.println(t);
}
if (t== 'F'){
void forward();
}
if (t== 'B'){
void backward();
}
if (t== 'R'){
void right();
}
if (t== 'L'){
void left();
}
if (t== 'S'){
void stopp();
}
}
I'm using an Arduino UNO on version 2.3.4 of the IDE. I have tried using two different cables, on both the USB ports on my laptop.
Please help.
Hello, I recently bought this module (link) and I thought I could use it to power arduino with 3 18650 batteries and recharge them with solar power. The module itself works, batteries recharge correctly and all but if I attach an arduino board to it (through the 5V terminal not usb-c) the board powers up and runs for a minute and then shuts down. Is it because arduino isnt't consuming enough current, I am using the wrong terminal or is the module broken? Thanks for any help
Hi everyone, i'm building a PID controlled arduino car with TT motors and want to measure the input voltage into the motor. To do so, I connected a wire from the output screw terminal of the motor driver to a potential divider, before connecting the scaled down output into an analog pin. However, despite measuring the exact values of resistance of the resistor and providing a regulated 4.5V external AREF with a buck converter (all measured with multimeter), i can't obtain accurate values for input into the analog pin. I've tried a different pin as well with the same issue and the pin worked fine previously for an encoder input
When using the external AREF, i keep getting a constant 1023 from analogRead, despite the measured voltage at the pin being 3.6V, much lower than the 4.5V. |
When using the internal 5V reference voltage, measured to be 4.88V, the values are constantly off by about 1 Volt, with the actual voltage across motor being 5.4V and the measured and upscaled voltage being 6.4V. I suspect my resistors are 5% and not 1% resistors, but would that matter? As i measured the actual values for each resistor.
What are some possible causes for this? I don't think it is a wiring issue as when measuring the voltage directly at the analog pin and doing the potential divider calculations manually, I end up with a pretty accurate value. Or is this inaccuracy typical of measuring voltage this way and do i have any alternatives to measure the input voltage into the motor?
Would greatly appreciate any help and guidance. Cheers!
#include <Arduino.h>
#include <SoftPWM.h>
#include <PID_v1.h>
float runPeriod = 30; //seconds
// potential divider left: 5.11, A0, then 9.99k , right: 5.08k, A1, then 10.20k
const int encoder0pinA = 1;//A pin -> the digital pin 1
const int encoder0pinB = 2;//B pin -> the digital pin 2
const int encoder1pinA = 3;//A pin -> the digital pin 3
const int encoder1pinB = 4;//B pin -> the digital pin 4
const int inAB = 5; //Motor A input B
const int inAA = 6; //Motor A input A
const int inBB = 9; //Motor B input B
const int inBA = 10; //Motor B input A
void setup() {
Serial.begin(9600);
pinMode(inAB, OUTPUT);
pinMode(inAA, OUTPUT);
pinMode(inBB, OUTPUT);
pinMode(inBA, OUTPUT);
analogReference(EXTERNAL);
SoftPWMBegin();
}
double readleftVolts() {
double leftrawVolts = analogRead(A0) * (4.5 / 1023.0);
return leftrawVolts * ((9.99+5.11) / 9.99);
}
double readrightVolts() {
double rightrawVolts = analogRead(A1) * (4.5 / 1023.0);
return rightrawVolts * ((10.22+5.07) / 10.22);
}
void advance(int s) { // Motor Forward
// Motor A: Forward
SoftPWMSet(inAB, 0); // Motor A Input B Low
SoftPWMSet(inAA, s); // Motor A Input A High
// Motor B: Forward
SoftPWMSet(inBB, s); // Motor B Input B Low
SoftPWMSet(inBA, 0); // Motor B Input A High
}
void loop() {
advance(150);
Serial.println(readrightVolts());
if (millis() > (runPeriod * 1000)) {
stop();
Serial.println("stopped");
while (true) {
}
}
delay(100);
}
I've got an application where one Arduino will essentially make a request over a potentially open line. I'd like to make at least some effort to verify the origin of the request is a valid source. It's not a high-security application, but I want to put in the bare minimum.
I'm thinking something like the receiver will acknowledge the request with a pseudo-random, 32-bit number. The requester will take that number and run it through a function that spits out another pseudo-random, 32-bit number. Then the requester will send the answer back to the receiver so it can compare the results to what it expects (it knows the same function). And presumably, even if you overheard several pairs of input-output pairs, it would take a bit more than a high-school diploma to figure out the pattern
I figure there's got to be some well known, fairly simple functions to do this. Maybe even a library.
I have the elegoo nano, and I can't seem to figure out if the LED lights on the front come on when things are working or when things aren't working?
Is there also any good tutorial for how to connect the nano to IDE? I've got the driver installed, but I'm not sure if the sketch is being uploaded as it's not running my servo motor.
I know it's a dumb question.
I bought several light kits for Lego sets. They have remote operated microcontrollers that have different flash patterns preprogrammed onto them. Those don't match what I want them to do. Can someone here walk me through how to change the programs on the boards? I have VS but my pc doesn't even recognize that the chip is there when I plug it in via usb.
Overcomplicating a 7segments clock
i had this idea a few years back. so, i want to build a 7 segment clock(not on a display but a physical clock) but the twist is that i want to make the the segments rotate pivoting on the segment end(see picture) so that the ones that are “off” hide under the ones that are “on”, im a web developer so my arduino skills are near zero and im trying to use claude for some help but i feel like im overcomplicating something, i tought about using 28 individual servo motors(1 for every segment) to make the pivot aspect, is there maybe a simpler way, i would really appreciate some help with the components
The arduino is recognized by my computer but not by the school computers so I am trying to find the problem. The school computers do not show any ports when we check, not even ports without boards. The boards may be third party and we do not know the names of the boards. I will attach an Image.
I’ve attached a picture - am I right in thinking I don’t have a built in LED soldered to my board??
Hi guys ! i bought some chinesse ESP32 wroom32d and i'm trying to connect to it but i get error :
Info : Listening on port 50001 for tcl connections
Info : Listening on port 50002 for telnet connections
Error: unable to open ftdi device with description '*', serial '*' at bus location '*'
How to connect to it ??????/