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
-3
votes
1answer
34 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
83 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
28 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
35 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
87 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
144 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
31 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
56 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
65 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
46 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
25 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
31 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
24 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
45 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
34 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
73 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
59 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
24 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
81 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
304 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
125 views

Garbage Characters Being Sent from HC-05

I have a contraption that uses a HC-05 Bluetooth module and sends info to a processing program which controls the contraption. The processing program is a follows (from a video by How To Mechatronics,...
0
votes
0answers
53 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
41 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
38 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
38 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
72 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
79 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
61 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
58 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
171 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
76 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
50 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
132 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
52 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
52 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
151 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
85 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
344 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 ...
1
vote
1answer
1k views

Why is dtostrf() not working for this one value?

I'm building a weather station using an ESP32 and BME280. I'm feeding the data via MQTT and Python into a database that is then used to make a nice dashboard for the data. The MQTT message needs to ...
0
votes
1answer
421 views

Problem “Didn't find PN53x board” Arduino NFC Card Reader

i am using the elechouse PN532 RFID Module with an Wemos D1 mini in the Arduino IDE. I use the ISO1443a_uid example from the elechouse library. All works fine if i plug the USB Cable into the wemos ...
0
votes
0answers
432 views

Nested “switch” statements menu

I know that menus were discussed perhaps a thousand times here and everywhere. But using a ready solution is not something that I'm looking for because I know I won't learn the concept if I use them. ...
-1
votes
1answer
77 views

Am I able to set up a code where I can have two ways of turning something on?

I am pretty new to Arduino. I've created a code with the help of many YouTube tutorials to control a servo with a button. I decided it has gotten a little un-exciting so I've been trying to add a ...
1
vote
1answer
163 views

New code results in audio noise

I am working on a circuit that can record audio to an SD when a switch is HIGH and stop recording when the switch is LOW. I am using the TMRpcm library. I previously had an issue solved on these two ...
0
votes
1answer
286 views

Ultrasonic sensor showing weird reading

When i run a test code in Newping library for ultrasonic sensor SR04 then in works properly but when i run the actual code for obstacle avoiding robot then it shows 0 cm everytime. This means that ...
-1
votes
1answer
215 views

how to code LED turning signals on smart car [closed]

this question is regarding how to add turn led signals on arduino powered smart car. I have 4 leds to give turn indications on my smart car(line follower, obstacle avoider, Bluetooth mobile controlled ...
-1
votes
1answer
298 views

esp8266 WiFi Cannot Connect to a PHP Server

I am using a magnetic float switch sensor to monitor water level in a tank. I am using a ESP8266 board. I am trying to send the data collected by it to a php page in a host called "weris.link". I've ...
1
vote
2answers
130 views

Arduino pow() making 9's

I am having a temporary lapse of judgement, or not understanding how the power method works, but when I put 10 to the power of a number, it is that value -1. So: 10*10 = 100 Then I would assume, 10^...
0
votes
1answer
25 views

Arduino loop over a function is always displaying 0 as final values

I trying to loop over a function in arduino to get values for 2000 times, and then divide it by 2000 to get an average offset: int16_t x_offset = 0; int16_t y_offset = 0; int16_t z_offset = 0; And ...
0
votes
1answer
188 views

Trying to use Tap Detection solution using ADXL345 with Arduino

I am using ADXL345 sensor connecting with Arduino via I2C interface, I am able to test the data at tri-axial axis but as there are some other features also, which I am going to try with Tap detection ...
0
votes
1answer
58 views

Compile Error for Arduino Sketch

I am attempting to increase the volume of a Max9744 20 watt amplifier from Adafruit using an Arduino sketch. I am just a very beginner and working with my grandson, this may be more than I am capable ...