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
0
votes
1answer
24 views

Storing IR Sensor value not working

This is my first time working on Arduino for my project and I ran into an issue. I'm trying to make a very simple Vending Machine. Coin or any obstacle passes in front of the IR sensor and based on ...
0
votes
0answers
48 views

Why doesn't this code work as expected? [closed]

I expected the LED on ld1 (pin 7) to flash with a period of D1 (300) milliseconds. Similarly for ld2 (pin 8) with a period of D2 / 1000ms. int ld1 = 7, ld2 = 8; /// led out put int D1 = 300, ...
0
votes
0answers
36 views

I2C master's output is always 255

we are using 2 Arduino UNO as a master/slave for this i2c protocol. we used the first Arduino(slave) as a sensor that will input dummy data (in this case, temperature data). the Arduino(master) should ...
0
votes
0answers
37 views

problem controlling rgb led with one button

I'm trying to make a lamp which quality to change color by pressing a button, pressing once turns on red, pressing again turns on blue and so on, but I also want it to have a light effect in which it ...
0
votes
1answer
27 views

Condition in a while loop not updated on my mkr1010

I am using a server-client system where i send data from the server to the client to turn on a led (the onboard led). Led must be turned off using digital input (labeled 7 on the connector). I use ...
0
votes
0answers
11 views

I am trying to rewrite an RFID with a MEGA2560 and a RFID-RC522

I have been trying to rewrite an RFID tag so it is the same as my other one. I have code that will read both separately but I cannot find any already written for the MEGA2560 that will work for me. ...
0
votes
1answer
50 views

Monitoring multi analog ports with ACS712 current sensors

Making a Auto Blast Gate for dust collection in my wood shop. Arduino Nano using ACS712's to detect when tool is in use. Using DRV8825 to drive a single Stepper motor that will spin a disk to line up ...
0
votes
3answers
80 views

What are examples of large Arduino code bases and how are they organized?

I'd like to find out: how big can an Arduino project get, is there some limit? are there examples of large open source code bases? I did some research but find only example projects with single .ino ...
0
votes
0answers
30 views

Potentiometer motor system is not working

I am setting up a potentiometer system that includes a motor that is supposed to spin with the potentiometer changing the speed of the spin and a button to reverse it. I checked the coding and it is ...
0
votes
1answer
38 views

Return photo stacking rail to start

In isolation (73 years old) and trying to get my macro photo stacking rail to return to start without a limit switch. I know the number of steps taken, so it is just a matter of reversing the motor. ...
1
vote
0answers
107 views

Error compiling for board Arduino Nano 33 BLE

I am trying to use pulse sensor with Arduino Nano 33 BLE sense, but when I verify it, it shows Error compiling for board Arduino Nano 33 BLE. The code is from the pulse sensor website. The code works ...
1
vote
1answer
47 views

Thermocouple and multimeter

I've put together this script that should allow my Arduino Mega to be show thermocouple readings on the serial monitor, whilst also showing readings of voltage and ohms across a given component. I'd ...
1
vote
1answer
272 views

How to Set the Control Register on the DS3231 RTC module for Arduino UNO R3?

I am using the DS3231 RTC connected to an Arduino UNO R3 for a project. I won’t go into detail, but I need to save power, therefore I am using the DS3231 Alarm Interrupt to wake the Arduino from sleep....
-3
votes
1answer
54 views

What is PWM actually? [closed]

tcommand=(pwm_value-480.0)/8.22; flapmag=(pwm_value-880)/41.0+10; In this piece of code used in arduino, I don't understand why PWM value is subtracted and divided like this. This is not my code. Any ...
0
votes
1answer
164 views

How can I interrupt a delay() when a button is pressed?

I have created a device that allows my son to track time spent on activities and exchanges that time into a time he can use with his electronics (eTime). Full code in GITHUB I am having trouble ...
0
votes
0answers
31 views

RF24 code not working:

I watched this video and used his transmitter code and receiver code. However, it's not working. There's no response from the receiver. The transmitter stuck at the loop: if (!radio.write( &data,...
-4
votes
1answer
48 views

expected '}' at end of input

hi i am getting this error, im guessing i have a bracket missing or one in the wrong place. any help is appreciate, still new at this. thank you (code bellow) #include <Wire.h> #include <...
1
vote
1answer
236 views

ESP8266 Webserver ESP8266WebServer variable html page (not as one const char)

The aim is to display a non-static html page depending on some variable condition. The code I created hast the problem, that the esp8266 is ressetting in the moment I request the page. const char ...
1
vote
1answer
286 views

ESP8266 Webserver ESP8266WebServer move Handler-Function in separate .h .c file

The plan is to create a bigger project and to split the ESP8266 webserver-code over several modules (.h .c files). The main problem is that the ESP8266WebServer server is not declared in the index.h ...
0
votes
0answers
50 views

How tocode and connect Quectel Bg96 development board to thingspeak?

Recently I have purchased a development board and I wanted to connect some sensors and send value to thingspeak(IOT cloud platform). Can Any one help me code please !!!!
0
votes
2answers
84 views

while(1) inside if conditional

if (!MDNS.begin("esp8266")) { Serial.println("Error setting up MDNS responder!"); while (1) { delay(1000); } } I know this will result in an infinite loop if the if conditional is ...
0
votes
3answers
98 views

arduino circuit review/ safety review

I have the following circuit It has a simple dc motor that is OFF, and switches ON once a day for 2 seconds. I use MOSFET IRF540N as a switch I use L7805CV as a voltage regulator I would like to ...
0
votes
0answers
67 views

lightshow project

Hello guys. I'm working on a little lightshow that has 3 extra feature's when i press the button. depending on the variable counter the lights should do something and it should message you that you ...
-1
votes
1answer
36 views

Sound sensor's output stucks to high values when I include a delay in the loop function

I use Waveshare's Sound Sensor module. I use this simple code to test the module: As you can see, the problem is that when I have a delay in the program, once the analogRead is bigger than 10 (by ...
0
votes
0answers
41 views

when submit data to ESP8266, ets Jan 8 2013,rst cause:4, boot mode:(1,6) wdt occurs

I am trying to make my ESP8266(nodemcu) as a Web server. When my code operates, and user connects esp's wifi and enters '192.168.4.1/set_peroid' by IE or chrome, this webpage appears: This is ...
0
votes
0answers
28 views

How do I get my servo to turn using bluetooth, is this a glitch?

I'm very new to coding with arduino so please excuse my naivety, For an electronics assignment I am making a servo turn back and forth using a HM10 BLE however each time I press a button that sends '0'...
0
votes
1answer
65 views

Arduino Mega TIMER1 one second interval

Is this timer set correctly for Arduino Mega? It should count exactly one second. And why when I print in serial monitor (seconds_passed++) is it incremented by 2 not by 1? Full code on Pastebin: ...
0
votes
2answers
39 views

My push button code doesn't work properly

I'm using an OLED display connected to a push button. I am trying to get my display to show two different values independently by using the push button to switch between them. Here is a snap of my ...
-1
votes
1answer
76 views

Refactoring bad design?

Could someone help me how to refactor old very complex code ? Original used just setup and everything else was in single ISR. But as it was bigger and bigger, code is quite slow and quite random ...
0
votes
1answer
65 views

A confusing condition statements [closed]

I am working on a project in making a timer socket using Arduino and a current sensor. For the code I decided to modify a code that was meant to be a kitchen timer. In that code I found a statement ...
0
votes
0answers
27 views

How do I have this audio and LED activate ONLY when a button is held using an Arduino?

I have this code that I am using to play a sound effect where I used a program called wav2c to convert a .wav file to number values that I put into a header file that I use in the code to generate the ...
2
votes
1answer
108 views

Why won't this code play a converted wav2c header file through an Arduino to my speaker?

I used this converter wav2c to convert a .wav file to a C that I can put in a header file. I was able to put converted audio into the h file but the program where I reference it does not seem to be ...
1
vote
3answers
452 views

Variable declaration inside main loop

In the past I declared variables inside the main loop which worked just fine. In a new project I did the same: void loop(void) { uint8_t counter; .... if (buttonPress) counter = 0;...
0
votes
0answers
90 views

Sending a union from Arduino via serial communication and parsing it in python

I want to send a union from Arduino to a python script running on a pc, and I want to parse the received union. I have read lots of topics online but I am stuck on how to do it in the most efficient ...
0
votes
1answer
43 views

RGB LED circuit problem

I have written the following code for RGB LED:- const int RED =11; const int GREEN = 10; const int BLUE= 9; void setup() { pinMode(RED,OUTPUT); pinMode(GREEN,OUTPUT); pinMode(BLUE,OUTPUT); } ...
1
vote
1answer
39 views

Code for two bulb fading alternatively

I have written this code const int A = 3; const int B = 5; void setup() { pinMode(A, OUTPUT); pinMode(B, OUTPUT); } void loop() { for(int i=1;i<=255;i++) { int j =255-i; ...
0
votes
1answer
79 views

Arduino Uno - Variables randomly changing

So I have a circuit for a timer (I don't think it is the problem) Sorry for it being a little messy. And I have this code (probably the problem): // LiquidCrystal - Version: Latest #include <...
1
vote
1answer
90 views

Seeburg Consolette Jukebox

I am working on a Seeburg Jukebox wall unit, I have it playing one track at a time form a SD card no problem. But what I need help with being new to programming is: 1. The code is long because it can ...
2
votes
2answers
84 views

arduino LCD help

I am trying to create smart clock with alarm using an Arduino Uno. My problem is when I set the alarm, I can't set the alarm again. Every time I must power off my Arduino and then power on in order ...
0
votes
1answer
77 views

Can someone check my code? My Arduino isn't doing a consistent count cycle

I'm wondering if someone could have a look at my code and let me know if there's something wrong with it. I had the code done for me a while back and did a quick test and it seemed to work. I have now ...
0
votes
1answer
76 views

connection of led with dht and code combination

Hi again? I saw my last question did not come out well, so let me rephrase it. Ideally, my project is composed of 3 sensors: 2 dht-22 sensors and an mq-7 sensor. For the dht22 sensors, I am using ...
0
votes
1answer
330 views

How to Simulate and Tune a PID

I've been trying to simulate a PID using Brett Beauregard's PID library in order to understand it better. Here is my code. #include <PID_v1.h> const unsigned int numReadings = 500; double ...
0
votes
3answers
96 views

Not able to split string into 2 char

I am trying to split an incoming string into 2 integer values since I have to control 2 dc motors with it. The processor is node MCU and I get following error:- Com Port Reading:- WiFi connected ...
0
votes
0answers
54 views

Analog pins giving off the same value

So recently I made code that used two custom sensors that are connected to the analog pin A0 & A5. Schematic can be seen here (http://inmoov.fr/test-your-finger-sensor/). const int ono = A0; ...
0
votes
3answers
167 views

delay() not working inside loop() block

Edited and attached code here. This section didn't execute. The delay(15000); doesn't execute, I mean the sketch didn't execute this line no matter where to put it. // include the SPI library: ...
1
vote
0answers
70 views

Help with code for changing motor speed depending on MPU6050 angles read

I have been trying to create code where my MPU6050 is constantly reading the angle it is at and based on that angle, increase or decrease the motor speed. For example the motor will be off when the ...
-1
votes
1answer
67 views

Code causing Servo motor not to work!

My sketch is compiling and loading, but when the program runs, the Servo motor does not work. The buttons work, the LED light works, Piezo buzzer plays the melody, the Stepper motor works but not ...
0
votes
1answer
262 views

Proper use of the tone() function within the loop () function [duplicate]

I am trying to have my sketch run a short series of tones (melody) through a Piezo buzzer after a selection is made by the user. I am getting a compilation error with my use of the tone function in ...
-2
votes
1answer
91 views

Arduino Code 'Bug'

I'm sharing my code.. The problem I am facing is that the code performs all the functions that are to be called except showing the MAX30100 (for heart rate) readings. I have tried this code using ...
0
votes
2answers
465 views

Combining 2 sensors in one code with 1 push button

I am trying to create a circuit with one tactile pushbutton, and LCD and two sensors: 1) temperature, and 2) pulse sensor. When the circuit is on, the LCD initially shows the reading from the temp ...