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.

Filter by
Sorted by
Tagged with
5
votes
3answers
782 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 ...
1
vote
2answers
64 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
2answers
39 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 (...
0
votes
1answer
51 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 ...
1
vote
1answer
101 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
0answers
50 views

Curve fitting Gnuplot session for mapping voltage on a sensor and outputting a value in liters [closed]

I have another post regarding mapping voltage on a sensor and outputting a value in liters. Code for mapping voltage on a sensor and outputting a value in liters There is a great answer by user ...
1
vote
0answers
75 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
0answers
45 views

C code help. A new line is being printed in a scanf because im printing a string and a int together. Need help. New to c code [closed]

#include <stdio.h> #include <ctype.h> int main() { int i; int h; int InitalCoin; char a[20]; printf("Enter the name of the customer: \n"); ...
1
vote
2answers
236 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
1answer
330 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
2answers
53 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 ...
0
votes
0answers
35 views

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 [duplicate]

**void setup() { pinMode(11, OUTPUT); pinMode (4,INPUT); } void loop() { int y= digitalRead(6); // push button 2 static int counter {} ; int x= digitalRead(4);// push button 1 ...
1
vote
1answer
80 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
1answer
42 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 (...
0
votes
2answers
110 views

Implementation help with difference equation [closed]

Implement the below difference equation Y[n]=04142y[n-1]+0.2929(x[n-1]) Assuming an implementation sampling frequency of 8khz any help with code would be great :)
1
vote
0answers
79 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
0answers
55 views

I2C and SPI connection in the same-time [closed]

I want to make code between to devices , the communication between the I2C master to master , but in the sometime the one of the connect with other device SPI bus master to slave . how it work?
1
vote
0answers
40 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
0answers
50 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
0answers
55 views

Master and Slave Code using 2 Arduino. 1 for PC and 1 for Sensor

I'm trying my gesture sensor to act as a keyboard. I'm using 2 Arduinos to communicate; 1 is connected to the PC (Arduino Pro Micro) and 1 is connected to the sensor (Arduino pro mini) Can you tell me ...
0
votes
1answer
152 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
0answers
250 views

Node MCU code is stuck in while (WiFi.status() != WL_CONNECTED)

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
0answers
159 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
1answer
116 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 ...
3
votes
2answers
569 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 <= ...
2
votes
2answers
51 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
1answer
60 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 ...
0
votes
1answer
168 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 ESP32, a plug-in water heater, and an AC relay board. The ESP32 controls the relay ...
1
vote
0answers
48 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
1answer
52 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
0answers
44 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
0answers
45 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) ...
1
vote
1answer
66 views

Looking to optimize this code and add a loop

So I want to optimize this code and add a loop to the two red LEDs. The process is green LED is flashing, press button, yellow LED blink for 3 secs and then alternate flashing between the two red LEDs ...
0
votes
1answer
44 views

How might I add a delay, close the servo and go to the start again?

#include <Servo.h> Servo myServo; const int piezo = A0; const int button = 2; const int yellow = 3; const int green = 4; const int red = 5; int knockVal; int buttonVal; const ...
2
votes
0answers
82 views

Please help with my tinkercad code. Debouncing stopwatch with lcd

#include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); int ssPin = 8; int resetPin = 9; bool cntrRunning = false; int sec = 0; int min = 0; double currentMillis; void setup() { ...
1
vote
1answer
84 views

Esp32 not connect with WiFi

I'm trying to connect WiFi at home in my esp32 but in the serial monitor shows a looping connecting to WiFi but never connect. look this The link that I followed. To my application. I want to connect ...
2
votes
1answer
225 views

Measure Vcc on ATtiny13a?

I am trying to figure out if I can measure the Vcc of attiny13a, but the code I use for arduino's and attiny85 does not work. This is where I got the code from. I know that it works by using the 1.1v ...
1
vote
1answer
103 views

Help in personal alarm clock project, cant write time on seven segment display

I'm trying to make a type of Arduino alarm clock, which when the time I inputed is equals to the current time, a servo will turn on my lights. It basically consists of a Keypad, an RTC DS1307 and a ...
1
vote
4answers
92 views

Why does the following code not cause the led's to flash but rather stay on continuously

int timer = 1000; int thispin = 5; void setup() { for (int thispin = 5; thispin < 8; thispin++) pinMode(thispin, OUTPUT); } void loop() { for (int thispin = 5; thispin < 8; thispin++) ...
1
vote
1answer
127 views

Understanding Debounce code

I don't understand the following Debounce code. (The complete code is at the bottom.) From what I understand, when the pin reads something, we wait at least 50 milliseconds before performing anything. ...
-2
votes
1answer
85 views

Code for fish auto feeder not working [duplicate]

I've been trying to make this code work, but for some reason, it doesn't work for me, even if I do everything like in the tutorial. So I've tried to do a new code and the outcome was the same. The ...
1
vote
0answers
57 views

Help with code not working

I built a button box, everything is wired up and all of the push buttons work using the code below, but for some reason my rotary encoders are not working, well 3 out of the 4 are not working. Is ...
0
votes
1answer
425 views

I get an error saying, “exit status 1 expected initializer before 'void'.”

I will be wiring a switch to the Arduino that controls the voltage. When the I turn the switch it can adjust the voltage from 0 to 5. The overall task is to print the output voltage. The print is to ...
1
vote
1answer
84 views

FOR Statement Within IF Statement

The past few days I've had trouble with a FOR loop iteration within an IF statement. I have a 12V DC geared motor with magnetic encoder being driven by an L298N motor driver which is controlled by an ...
1
vote
3answers
1k views

Why are the Do While loops not stopping?

Ive been staring at this for a while now and I am going cross-eyed. I am writing a simply program to change colors of a 3 color LED. It is working, but then I noticed the LED would sometimes flash. ...
3
votes
1answer
709 views

Why is this looping?

I am trying to do something very simple. I want the LED to fade from full brightness to off. This works... However, the LED turns back on to full brightness and fades again, in a loop. I am not ...
1
vote
0answers
103 views

ESP32-POE/ISO unstable after 10 days of power up

i have one ESP32-POE and ESP32-POE and i'm using the Olimex RS485 module to read a power meter that is placed near the ESP32 (5 meters of CAT5 cable - 9600 8N1). My device has this workflow (it's ...
1
vote
1answer
85 views

inconsistent digital output on simple code

so im new on arduino coding, and i made this code, where i input from serial monitor and then use it as a command for digital write. the problem is, sometimes the code work perfectly but then when i ...
1
vote
0answers
174 views

How to Adjust MQ131 Sensor?

The problem Hey. I'm trying to use the sensor Mq131 to measure some ozone data in a closed environment, but I'm having some bad time to adjust the trim in the sensor and get results in ppb. By ...
1
vote
0answers
32 views

Issue with seial communication [closed]

I am a beginner with c and arduino and am trying to create a 'whack-a-mole' style game. I am having problems with the 'score' variable. At the moment, I am just trying to get it to print to the Serial ...

1
2 3 4 5