Questions tagged [programming]
The process of designing and writing source code as part of a program (or sketch) for Arduino. For questions about uploading code to an Arduino board, use the [uploading] tag instead.
1,680 questions
2
votes
2
answers
150
views
Receiving incorrect Data through CANbus MCP2515, Nano to Nano - Data points 3, 5, and 7 only go to 7 bits instead of 8?
We are trying to get two Nanos to communicate via CANbus, using MCP2515 shields. I have decided to use the autowp/arduino-mcp2515 CAN interface library for the code. I've based my code off their ...
1
vote
1
answer
234
views
Can one re-program a Leonardo Eth via its Ethernet port only?
Let's assume we have an Arduino Leonardo Eth running some sort of networking application, perhaps a very simple web server. Importantly the server is read only and static HTML. There is no ability to ...
1
vote
1
answer
96
views
Reading JSON from Arduino via Serial Missing Parts of Message
I have a project (Digital Dashboard for a Motorhome) in Pi that reads JSON data from an Arduino board and sends it via Serial.
The Pi gets the JSON data, makes some adjustments and then sends it to an ...
1
vote
1
answer
114
views
include directive for external libraries
I added the Adafruit_GFX_Library to my Windows.
I used Arduino IDE, Tools > Manage Libraries > Install.
In preferences, Sketchbook location is set to d:\Alex\Hobbies\Electronic\Learning Arduino\...
0
votes
2
answers
207
views
How do I read data from a 32 bit I2C register address?
I'm having trouble reading the I2C data from the CPS8200, that has a 32 bit Register Address. Since I'm not too familiar with I2C register addresses more than 8 bits, and right now I'm not sure if I'm ...
0
votes
1
answer
127
views
Stepper motor not moving
this is my second Arduino project and I am trying to figure out why my stepper motor is not moving. I was able to get a basic 28byj-48 stepper motor to work using stepper.h and some sample code.
Now I ...
1
vote
1
answer
57
views
When I run my for loop the serial monitor is giving very strange results
This is unfinished code for driving a 4 digit 7 segment display. When I run my data function that should output the data to send to the shift register, I get a very weird output.
0 00111111
1 00111111
...
0
votes
4
answers
165
views
Adding multiple or's in line to condense amount of if lines
I have edited my question for more clarity. I am including the whole sketch. I tried to do a shorter version of my sketch, for this question, which had some typos in it and the way it was wouldn't ...
0
votes
1
answer
90
views
`sprintf` of %04d and %03x at the same time on Arduino
I have this code, work fine!
uint32_t id , id2;
char s[64]; // Should be enough
...
id2 = id = CAN.getCanId();
sprintf (s, "%04d : ", id ); // !!! HERE !!!
Serial.print(s);
the ...
0
votes
0
answers
127
views
ESP8266 Not Booting Properly on First Power On – Works After Restart
I'm working on an ESP8266-based water level monitoring system using an ultrasonic sensor and an I2C LCD. The problem I'm facing is that sometimes the ESP8266 does not boot properly when powered on for ...
3
votes
1
answer
108
views
Using a while loop in setup function to read sensor data
I have an Arduino vehicle and I upload projects to it that I want them to function once I use a strong light on a light sensor attached to A4 analog pin. So far, I have used the following code:
void ...
-1
votes
3
answers
156
views
Can you set up Arduino code to run once for a model display?
Rather hesitant to ask this question, as I have read a few comments on here that I feel are rather condescending. But at the same time some have been very helpful.
I have been building small scale ...
0
votes
0
answers
147
views
Initializing both I2C devices of a RP2040 Rpi Pico with Earle Philhower Core
I'm using the Arduino IDE (v1.8.19) with the Earle Philhower core to program a Raspberry Pi Pico (RP2040) board.
I2C bus 0 of the Pico (pins 4 (SDA) and 5 (SCL) are coupled to a first MCP23017 port ...
0
votes
2
answers
138
views
Difference Between delay() and a while Loop with millis() in Arduino?
What are the practical differences between using delay() versus a while loop with millis() for timing in Arduino projects? I assumed both methods are blocking, but I'm not completely sure.
Example ...
0
votes
1
answer
270
views
Questions about ATMega8A including burning my hex files
I wrote a small blink program for an ATMega8U-DIP I bought recently. The source is this,
#ifndef F_CPU
#define F_CPU 16000000
#endif
#include <avr/io.h>
#include <util/delay.h>
int main(...
-1
votes
1
answer
63
views
Musicbox freezes or can no longer find songs (FeatherRP2040, VS1053, Neokey1x4 x 2, RotaryEncoder)
I have a problem with my code for a music box that has the following features.
Using two neokey1x4 I can switch between folders on the SD card and press play/pause, stop, next song, previous song. ...
-1
votes
2
answers
517
views
Open drain without pull-up
Looks like I didn't make myself clear, sorry. Update to clarify things / TL;DR version:
4 Arduino UNO pins are connected to respective DE-9 pins, responsible for UP, DOWN, LEFT, RIGHT directions
...
1
vote
0
answers
117
views
"Stack canary watchpoint triggered (loopTask)" when synchronizing with Arduino Cloud IoT (ArduinoCloud.update())
I have created a sketch that updates 195 variables : 16xString variables, 34xfloat, 52xint, 107xbool.
Notice : I'm using the IDE tool instead of the included Cloud IoT compile (because I have a pb ...
-2
votes
1
answer
183
views
Controlling Vintage floppy drives
After researching a solution to a problem I want to solve, I'm hoping the third time posting is a charm. :)
I'd like to use an Arduino to control a vintage floppy disk drive. I'm looking to use it as ...
-1
votes
1
answer
122
views
Sending data through LoRa with ESP32-E
I have an Esp32-E from Firebeetle and LoRa from SBComponents. On both of these devices there are RX and TX pins. I believe that LoRa pins are just an extension of pins found on the Firebeetle.
My ...
1
vote
2
answers
151
views
Multiple threshold crossings trigger multiple LEDs - but only one at a time
I'm calculating the acceleration magnitude vector from an accelerometer inside a thick PU mat. When the mat is hit, depending on the value I obtain, only one of two LEDs, later more, shall light up ...
0
votes
1
answer
90
views
Arduino TFT Touch Screen Interface Only Returns One Button Option
I'm trying to create an arduino code that returns a value for the button that was pressed as the user choice. However, whichever button I press the only return is 2. Also, whenever pressing other ...
2
votes
1
answer
115
views
Code for a load cycler seems to be stuck
I am trying to make a battery load cycler to charge and discharge a battery repeatedly for a certain amount of cycles and here is my code:
bool in_charge_mode;
int cycles = 0;
float cutoffvoltage = 2....
1
vote
1
answer
220
views
Using WiFiServer in blocking mode
I am learning ESP32 network programming and I started by writing a simple telnet server. It uses a WiFiServer object to listen on port 23 and just log anything it receives to the serial monitor.
...
2
votes
0
answers
131
views
My code got my Nano ESP32 into a <500ms reboot loop
I have done a lot of reading and learning after previous help here and it has been great.
I have uploaded and tried many iterations of my code which all worked (Assuming my code was actually good) and ...
2
votes
1
answer
227
views
Need help with programing the LCD for my project
I am trying to make a digital die for my project at school. I am having trouble with the programming. I don't really know how to write code and I am not a programmer.
I took inspiration from a post on ...
0
votes
1
answer
151
views
Programmer vs target clock frequency
I have a 16u2 programming a 1284P for a custom board I am building. The 16u2 converts USB to USART for programming the 1284P, however the 16u2 has a maximum frequency of 16MHZ while the 1284P has a ...
-1
votes
1
answer
106
views
No new random number generated
I made a teddybaer with buttons, LEDs, and voice output for my son. There are some buttons with pictures of our family with LEDs behind. The adruino is connected to a DfPlayer mini.
After pressing a ...
1
vote
0
answers
99
views
Weird issue with wire.requestfrom() and MailClient.sendMail() on ESP32- rst:0x3 (SW_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
Update_2: No change after Update_1, same error. I still have to comment either email, I2C, or Temperature out, that the other two can work.
Update_1: I'm also using a DS18B20 with #include <...
2
votes
2
answers
853
views
Arduino Digispark ATtiny85 conditional logic not working
Expected Behavior:
I am attempting to use && or nested if statements to achieve the effect of two switches being required to close prior to an LED light (i.e., flip both switches), the LED ...
1
vote
3
answers
954
views
Serial.println printing just after the previous string in same line
I wrote serial.println in my code but the string was printed in same line on serial moniter.
#include <WiFi.h>//for connecting esp32 to a wifi
#include <TinyGPS++.h>//to obtain gps data ...
1
vote
1
answer
48
views
Code logic to measure values stored in buffer and created nested array
I am having a difficult time creating some logic in my code.
I have a potentiometer connected to an ESP32 to simulate a load cell and a range sensor. The value for the force is between 0 and 400 ...
0
votes
1
answer
98
views
ATtiny25 - assembly - BOD disable for sleep mode - error [closed]
If I understood the AVR instruction manual correctly, the ATtiny 25 can disable the BODlevel2 fuse by software, but when compiling with Studio 7 (version 7.0.132), I get the error "Undefined ...
-1
votes
2
answers
202
views
I need help for applying a logic to this code
Here's the code:
int softStart = A0;
int enable = A1;
int powerBTN = A2, powerState = HIGH, lastPowerState = HIGH;
unsigned long lastDebounceTime = 0;
unsigned long debounceDelay = 25;
unsigned long ...
1
vote
1
answer
277
views
Make two LEDs fade in and out with with different PWM values
I have two UV leds, one Vf 3.3V @ 150 mA and the second one Vf 5V @ 150 mA. I need a circuit to make them fade in and out alternatively, i.e., as one goes dimmer the other goes brighter and vice versa....
3
votes
2
answers
2k
views
is #ifdef __SD_H__ considered a bad practice?
Say I'm working on a library^1 to which I want to add support for SD.h^2 but knowing for a fact that many microcotrollers don't support SD.h (therefore they result in compilation errors [eg. Attiny85])...
4
votes
2
answers
351
views
"if" condition problem / question
I'm new to Arduino and my question is rather theoretical. I have an Arduino Nano board (Atmega168 processor), a button, a display. I have written a button handler that does not stop code execution. My ...
1
vote
0
answers
153
views
MKR GPS shield inconsistent GPS connection/data printing...library issue?
I have been using a MKR WiFi 1010 board with GPS shield for a very long time (year+) and have not been able to solve my problems with the GPS data dropping out.
The setup for my field application is a ...
0
votes
0
answers
289
views
Unable to program with AVR ISP mkII under Linux
I just got an AVR ASP mkII external programmer and I am unsuccessfully trying to program my arduino with it.
All the settings in the IDE are correct. This is the error message that I am getting:
...
0
votes
1
answer
203
views
Problem with Bing generated code for automated chicken coop door
Glenn from Sweden here. I was wondering if some kind soul could help me out here.
My partner bought a cheap chinese knock-off automatic chicken coop door that operates based on sunlight. Link to the ...
2
votes
1
answer
313
views
Read values from a txt file on an SD card
I'm trying to read a text file (has numeric values) from SD card. The values in the file like this
87 512
255
I need to read 87 in ch1 and 512 in ch2 and 255 in ch3.
Why did I get on 'SKIP_NONE' '...
-1
votes
1
answer
773
views
convert string representing a binary number to binary
I have a serial input "1111111" and I would like to convert this to a binary B1111111 that I can send to a led matrix.
I tried to search, but, all the results were misleading, led to full ...
1
vote
1
answer
308
views
ArduinoJson reading `null` from Serial
I have a setup that reads from serial when I sense that there is something to be read (and always assume that what is sent to the arduino is valid json):
void setup(){
Serial.begin(9600);
...
1
vote
1
answer
882
views
How to add one JsonDocument to another in ArduinoJson
I'm utilizing this json library: https://arduinojson.org/
I am attempting to write a function that creates a response object, and wraps an already built json document:
void sendResponse(
...
-1
votes
1
answer
561
views
SPI with DMA in a Arduino Due
I have a project where I need to store data (~16 Mo) on a memory and be able to fetch the data fast (<36000 bits/s) with DMA because I have other signals to take care of.
Currently I use an SD card ...
1
vote
0
answers
578
views
How to use multiple PN532 over i2c bus(es) and SPI?
I am working on a project that involves 3 PN532_modules to an ESP32, which sends the Tag_ID over BLE.
Plan A was to use One module on i2c_1, second on I2C_2 and third over SPI.
The SPI one works as ...
1
vote
1
answer
183
views
Programming barebones ATMega328 with external programmer and no bootloader
I have created a circuit with a barebones ATMega328.
I also have an external programmer (Sparkfun's Pocket AVR Programmer)...
Now I want to program a particular sketch... When uploading a sketch, do i ...
2
votes
1
answer
98
views
Functions delaying gesture sensor recognition
I am working on a simple little robot to cure my boredom and all it has is a 64 x 32 OLED for the eyes, and a PAJ7620 Gesture recognition sensor with a Seeeduino Xiao as the main board.
Basically, ...
0
votes
2
answers
218
views
How much readable text can fit inside an ATTINY85? Feasibility of scrolling a booklet on a 0.91-inch OLED display
I'm a total beginner, so I've been talking with Chatgpt regarding the capabilities of the Attiny85 microcontroller. But the AI would hallucinate a lot and give only partially right answers (because it ...
2
votes
0
answers
334
views
Arduino NANO RF reciever and Digispark Attiny 85 transmitter issues
I am trying to send RF signal from Digispark Attiny 85 (this one) and receive the signal with Arduino NANO V3.0 ATmega328 (this one). Transmitter and receiver are STX882 and SRX882 (these). Library ...