Questions tagged [code-review]
Code review is systematic examination of your Arduino sketch. It is intended to find and fix mistakes overlooked in the initial development phase, improving both the overall quality of software and the developers' skills.
253 questions
1
vote
1
answer
115
views
Arduino Mega 2560 + DRV8871: Motor Not Moving with PWM Control
I'm using an Arduino Mega 2560 to control a DRV8871 motor driver connected to a DC brushed motor. The setup includes:
Three buttons: UP, DOWN, and FAST
One limit switch input, where the upper and ...
1
vote
1
answer
84
views
Accelstepper: missing syncro in simple test program
I have the following test code, which I'm running on an Arduino Yùn. Only PulCyan and DirCyan are connected to Arduino, all the remaining pins are not connected (except ground).
If I run this program ...
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....
0
votes
1
answer
106
views
Keypad library isn't working or I am wrong somewhere [closed]
I am using PICSimLab to simulate a keypad. The configuration of the keypad is as shown in the picture:
and the code is:
#include <LiquidCrystal.h>
#include <Key.h>
#include <Keypad.h&...
1
vote
1
answer
209
views
Code review for timer using RTC and OLED screen
I am building a small art project to display my current age with an accuracy of 1/100th of a second. I am using a XIAO SAMD21, a DS3231 RTC, and a 128x32 OLED screen. Here is what it looks like right ...
-1
votes
1
answer
115
views
Arduino not reacting sometimes when reading serial commands
When I am sending hex numbers via computer to the arduino leonardo, it sometimes won't react, but the serial monitor says that it was sent. My code;
void setup()
{
Serial.begin(9600);
pinMode(...
1
vote
1
answer
150
views
Sounds are being played at the same time
I'm making a school project that allows plants to 'talk'. As in when the plant is in an un-ideal environment (low or high soil moisture, not ideal temperature or humidity and not enough light). I have ...
-1
votes
1
answer
272
views
error: expected unqualified-id before 'if' if (send) { but all semicolons are available [closed]
I am getting a compilation error: expected unqualified-id before 'if' . Btu I have check all the semicolons . Please help finding my error.
The rest of the message error reads
C:\Users\jecalderon\...
3
votes
1
answer
786
views
How do I use a transmitter and receiver to send string messages conditionally to a receiver?
I'm working on a project to build a plant monitor that works from the outside with Arduino that picks up light and water values from it's environment then uses a nRF24L01 with an antenna and I've come ...
0
votes
2
answers
138
views
Pin outping 1V instead of expected 5V, not hardware related
Heyo everyone !
I'm in a project where I need to send a signal if I detect vaccuum.
I'm sending the signal on PIN 9 but I soon realized that I was only getting 1V.
Tought I was alternating between ...
-2
votes
2
answers
93
views
how to convert a line of code for arduino to receive a value
im sending the value 1500 from another MCU with
fdserial_txChar(transmit, send >> 7); // send Higher 7 bits
fdserial_txChar(transmit, send & 0x7F); // send Lower 7 bits
and was ...
0
votes
1
answer
79
views
Combined code to run a 2-zone radiant floor system. Cannot get 'RadiantMain' to work. Better description in beginning of code [duplicate]
Trying to combine code to run a 2-zone radiant floor heating system. The menu code works perfectly. When I select MenuC 'Run main' it executes to RadiantMain prints test and then returns to menu ...
1
vote
1
answer
403
views
DHT11 temperature and humidity sensor Code
I’ve got a question about this code I’ve attached please- would it be correct to read it like this:
After defining the variable temperature and humidity and assigning measurement_timestamp to millis(),...
2
votes
1
answer
148
views
Ramping servo motor taking longer than calculated
I'm learning how to code a "BOE Shield bot" with a partner at my university (first year). To clarify for those that do not know: a BOE Shield bot is a small robot equipped with 2 servo ...
0
votes
1
answer
166
views
Single Method for 2 Ultrasonic Sensor is not working as expected
So I have created a method to read and return Ultrasonic Sensor Data. I have 2 Ultrasonic Sensors.
Below is my code.
// Ultrasonic Pins
#define T1 2
&...
1
vote
0
answers
287
views
Code question: LCD keypad Shield. How do I define the buttons?
I am trying to adapt a alarm clock sketch that used external buttons, but I would like to utilize a LCD Keypad Shield. The data sheet says all the buttons are on pin A0, so every button is "set ...
-1
votes
1
answer
192
views
Displaying multiple temperature outputs w/Thermistors
So I asked this question a couple days ago but did some more work with some of the coding, but I'm really stuck and need some help. I'm trying to display the temperature for each separate thermistor ...
3
votes
0
answers
517
views
Integration of MAX30100 and DS18B20 Thermal Probe Integration
This is for my final year project that I have been tasked with designing a patient monitoring system. However, during the last stretch of model prototyping, I am experiencing issues with my MAX30100 ...
1
vote
1
answer
146
views
I am trying to add a countdown to my Arduino code but it does 0 days, 04:09:36 instead of starting at 7 days
The code I use probably has a math problem since an Arduino can only count a 16 bit integer. This problem is with the WeekDelay() function.
The project is for an Aerogarden. It pumps water into the ...
1
vote
0
answers
129
views
RFM69 Sending Failure
Hi I'm trying to get the RFM69 rf module to work on an arduino uno.
Here is my code:
#include <SPI.h>
// Addresses for this node. CHANGE THESE FOR EACH NODE!
#define NETWORKID 0 // Must be ...
-1
votes
1
answer
160
views
I have been having a lot of trouble adding a countdown to a piece of code [closed]
This is the code. The /// are where I added the countdown. Unfortunately the countdown only goes down 9 seconds. What I want it to do is go down the full 24 hours. I have been trying to fix this error ...
1
vote
0
answers
39
views
servos act strangely instead of stopping/starting
I am trying to make it so that my robot rolls straight when pin 8 is high and stop when pin 8 is low, the 2 servos is constant rotation servos. instead the servos spin when the wire touches it pin ...
-1
votes
1
answer
61
views
'for loop' seems to change the execution of pow()
The first time, pow() works. But inside of a 'for loop', or again afterwards, it doesn't behave !? (I'm using a Chinese Pro Mini with Arduino 1.8.16)
EDIT
To clarify what I am asking, my question is:...
0
votes
1
answer
304
views
Two-Wire Interface (TWI) Frequency and SMBus Compatibility
Have I understood the ATmega328P datasheet correctly regarding the TWI clock frequency?
From §21.5.2 Bit Rate Generator Unit, the TWI clock frequency is calculated as follows:
Then solving for TWBR:
...
5
votes
3
answers
2k
views
How do I make another action repeat inside a loop?
So, I've just started programming Arduino (and also in general), so I'm doing basic things, like switching on and off LED's.
I've made them light in a sequence and then turning them off (in the same ...
2
votes
2
answers
314
views
Unwanted ghosting with charlieplexed LEDs
I have a very simple PCB that uses 3 GPIO on a ATtiny85 to control 6 LEDs using charlieplexing.
When I try to program certain patterns of lit LEDs (pseudo PWM) I get some LEDs lighting dimly when they ...
1
vote
2
answers
766
views
NodeMCU wont connect to Blynk
My NodeMCU wont connect to Blynk with my code but works fine with example code and same auth token and WiFi info. Cant figure out why its not working. Must be something in my code interfering with it (...
1
vote
2
answers
2k
views
HX711 Ridiculous speeds
I'm using a SparkFun HX711 board and an Adafruit AdaLogger (M0) Featherboard. I have cut the trace on the back of the HX711 to get a faster data rate (should be about 80 sps). I did this by reviewing ...
2
votes
2
answers
152
views
How to get 2 loop functions to cooperate?
I have a OLED SSD1306 & DS3231 RTC, 2 buttons to set the time & date. My project is to display a scrolling text at the top of the OLED, the RTC time in the middle, the day & date on the ...
1
vote
0
answers
144
views
Project doesn't work after 2 - 3 times, requires frequent turning off and on
I am new to Arduino and I am working on a project. This project inspired me and I tried doing it.
The following code was provided in the description:
int maxPeople = 5; // maximum number of people ...
1
vote
2
answers
434
views
Arduino code not working properly (Please Help)
I am having some trouble getting my board to perform the function I want it to perform. This is a project I have due in a few days, and I have hit a wall I just can't seem to get past. Now, I will say ...
1
vote
1
answer
1k
views
Multiple Wire.write() not working for Arduino Nano I2C
Code for Master
#include <Wire.h>
void setup()
{
Wire.begin();
Serial.begin(9600);
}
void loop()
{
Wire.beginTransmission(9);
Wire.write('c');
Serial....
1
vote
2
answers
332
views
Adding another flow sensor to sketch
Adding another flow sensor to sketch
I have a water flow sketch I use for my freshwater consumption. I would like to adapt it to use for diesel fuel consumption. The difference is with a diesel ...
1
vote
1
answer
202
views
Make an LED Turn
//Make an LED Turn ON after pressing a push button switch for five times. Add a reset switch to turn OFF the LED whenever the reset switch is pressed
**void setup()
{
pinMode(11, OUTPUT);
...
1
vote
1
answer
66
views
Explanation of code found online
i found following code online, to read the value of a touch sensor... i am having difficulties understanding how the 2 second timeout on the marked line works..
if ((touch_sensor_value (...
1
vote
0
answers
696
views
U-blox GPS module (and TinyGPS library): altitude data getting stuck at strange values
We have built a HAB (high-altitude balloon) tracker based on an Arduino and a U-blox GPS module, but we have a sporadic issue where the altitude data gets stuck at odd (usually low) values. The ...
1
vote
0
answers
955
views
How to stop my 16*2 lcd blink?
Here I wrote code for my weighting scale measurement. In which I added an on/off switch for my LCD display. But in defined delay time my LCD is a blink and I do not want it. I want my LCD switch on/...
2
votes
0
answers
88
views
Am I maximising my A0 readout rate with this peak-detection code?
I have a pulse going into A0 on a Nano, and want to detect the peak voltage. With low-pass filtering to slow down the input pulse I'm still reading marginally too slow.
The code overall inhibits a ...
1
vote
1
answer
1k
views
ESP32 preferences. One error returned, all others work. SOLVED
I am using the Preferences.h library in my Arduino code. I initialize some values. I save them with the preference library. I then modify all the values, then read back the original saved values.
All ...
2
votes
0
answers
3k
views
Node MCU code is stuck in while (WiFi.status() != WL_CONNECTED) [closed]
I am using the Node MCu V3 board ESP8266MOD
Board Manager Version: 2.7.4
Arduino IDE: 1.8.12
My code is stuck in the while (WiFi.status() != WL_CONNECTED)
Here is code:
#include <ESP8266WiFi.h> ...
1
vote
0
answers
2k
views
Wemos d1 mini code not uploading
I have a wemos d1 mini. I uploaded a code in wemos d1 mini and after that my wemos mini not working. I tried to upload another code in it even the led blink sketch and even a blank sketch but whenever ...
1
vote
1
answer
900
views
How to add two assembly arrays in arduino
Hey guys what I'm trying to do is to sum two arrays and return a new array; for example if given
uint8_t a[] = {2, 4, 6};
uint8_t b[] = {1, 2, 3};
I should get { 3, 6, 9} What I'm trying to do is ...
4
votes
2
answers
2k
views
How to move a servo quickly and without delay function
Im trying to move a servo from one place to another while using the typical for loop you find in the servo's library example:
int lightON = 180;
int lightOFF = 90;
for (pos1 = lightOFF; pos1 <= ...
3
votes
2
answers
307
views
How to move a servo with a function
Im currently moving a servo from one side to another by using the typical for loop like this:
int lightON = 180;
int lightOFF = 90;
if (buttonState == HIGH) {
digitalWrite(LED, HIGH);
for (pos1 =...
1
vote
1
answer
265
views
Turning on and off two set of LEDs with two tactile buttons
I have two sets of 4 LEDs.
Set A (Led1 Led2, Led3, Led4)
Set B (Led5 Led6, Led7, Led8)
Both sets have its own tactile button:
Tactile A,
Tactile B,
Tactile A, turning on the LEDs set A and tactile B ...
1
vote
1
answer
414
views
How to override automatic control in Blynk app?
I am a beginner to Blynk, and have successfully built a simple water temperature control project. It consists of an ESP32, a plug-in water heater, and an AC relay board. The ESP32 controls the relay ...
1
vote
0
answers
286
views
Why is my buzzer always on?
I wanted to make a buzzer go off when the distance measured by the ultrasonic sensor becomes more than 100cm. The things used in this project are a 4x4 keypad, an hc-sr04 ultrasonic sensor, and a ...
2
votes
1
answer
160
views
File created, but not logging data
I am starting using Arduino and have very little to none experience coding. However, I have managed to code and understand how it works.
The problem that I have is that I am unable to log (record) ...
1
vote
0
answers
90
views
Can someone check my schematic and code? My Led is not turning on
Led1 is on the left Led2 is on the right The code is making LED1 blink every second but it should also turn on Led2 so that whenever I press the push button it should turn off Led2. But Led2 isn't ...
1
vote
0
answers
75
views
Automatic water pump Trigger System - I need my code FIXED
int out = LED_BUILTIN;
int strt = 3;
int stp = 9;
void setup() {
pinMode(out,OUTPUT);
pinMode(strt,INPUT);
pinMode(stp,INPUT);
}
void loop() {
while(true) {
if(digitalRead(strt) == LOW) ...