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
11 votes
1 answer
249 views

Cloud function getting stopped Parse.com in loop when calling from Arduino-yun

I have created a cloud function using the Parse.com Javascript SDK and I am calling those functions from Arduino. Following is code for the hello function: Parse.Cloud.define("hello", function(...
Abhijeet Kulkarni's user avatar
9 votes
3 answers
2k views

delay(time); vs if(millis()-previous>time); and drift

Going through an old project, I had code on two Arduino Due that looked like this void loop() { foo(); delay(time); } taking to heart the majority of literature on using delay(); I recoded this ...
ATE-ENGE's user avatar
  • 921
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 ...
AndreFro's user avatar
5 votes
2 answers
7k views

DC Motor Speed Measurement using Rotary Encoder

I have written the following code to measure the speed of a unidirectional DC Motor.I have attempted to measure the time between successive interrupts in order to calculate speed. boolean check; ...
TechPakoray's user avatar
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 <= ...
Marcelo_M's user avatar
  • 121
4 votes
1 answer
2k views

NRF24L01 only receiving zeros

I'm attempting to transmit very simple data across some NRF24l01 modules for testing purposes, and I've been following a YouTube guide. Here is my code: Trasmitter: #include "RF24.h" #include <...
Wilson's user avatar
  • 41
4 votes
1 answer
271 views

Working with multiplexers for constant voltage output

I'm working on creating a circuit where I'm trying to have the ability to switch multiple strands of LED rope on and off at a time using an Arduino and a multiplexer. With my current configuration, ...
narner's user avatar
  • 267
4 votes
1 answer
1k views

Arduino Uno as keyboard

I am trying to make Arduino Uno to act as a keyboard. I have successfully flashed the USB-HID firmware in it using this link also and programmed it like this. uint8_t buf[8] = { 0 }; int inpin1 = 7;...
Mayank Pal's user avatar
3 votes
1 answer
718 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 ...
Keltari's user avatar
  • 163
3 votes
3 answers
2k 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;...
Sören's user avatar
  • 41
3 votes
3 answers
2k views

How to correctly use functions that return pointers to multiple typedef'ed types in Arduino IDE?

I have a program that typedef's two structs. Each one has a corresponding function that returns a pointer to it.... typedef struct { int x1; } x; x *a; x *f(void) { return a; } typedef ...
bigjosh's user avatar
  • 1,553
3 votes
1 answer
242 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 ...
Mario Ronci's user avatar
3 votes
2 answers
228 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 =...
Marcelo_M's user avatar
  • 121
3 votes
1 answer
110 views

My Arduino freezes if power removed from the HMI

I have an Arduino (Pro Mini) connected to an HMI display over serial. When the user pushes a button on the HMI screen, it activates a relay attached to one of the digital pins on the Arduino. For ...
Prdufresne's user avatar
3 votes
5 answers
13k views

Controlling Servo Motors with push button. Problem though

I have this setup where I have and Arduino Uno, a mini servo motor, and a pushbutton. I use a single pushbutton to control the servo motor to go to one position, then push it again to go back. It ...
Jeremy Rigor's user avatar
3 votes
0 answers
396 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 ...
Roschlynn Dsouza's user avatar
3 votes
0 answers
2k views

Encoder + Bounce2 Library

I am working towards debouncing my keyes rotary encoder using the Bounce2 library found here ( https://github.com/thomasfredericks/Bounce2 ). I believe the problem lies in my code as there isn't much ...
kevinconnectable's user avatar
2 votes
2 answers
189 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 ...
RedGrittyBrick's user avatar
2 votes
1 answer
815 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 ...
lostbeam488's user avatar
2 votes
2 answers
15k views

Getting error ets jan 8 2013,rst cause:4,boot mode(1,6) wdt reset

I'm working on a project to send ultrasonic sensor data to my webserver. For that I'm using ESP8266 WiFi module, 3.3V regulator IC by giving input volt of 5v from aduino uno. I successfully uploaded ...
Touseef ahmed's user avatar
2 votes
2 answers
1k views

IR Remote code not activating ON/OFF states

The code below is for turning RGB lights on/off. The connections are as indicated in pin numbers. I found the resulting value of the buttons of the remote but when I used them in code it is not ...
PRATIK AHUJA 's user avatar
2 votes
3 answers
457 views

Why do I get a compiler error when I'm pretty sure I have such method?

Code (I've omitted much of the code, and left just the outline and code probably relating to the error.) SelfDrivingCar.ino #include "JKMain.h" void setup() { JKMain::setup(); } void loop() { ...
Fine Man's user avatar
  • 189
2 votes
2 answers
444 views

Controlling two AC devices, device turning on incorrectly

I am making use of the code below to control the speed of an AC fan and the intensity of an AC Lamp with an Uno. The problem I am having is that, when I set the lamp intensity to low or medium, the ...
Imraan's user avatar
  • 23
2 votes
1 answer
78 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 ...
ShootinLemons's user avatar
2 votes
1 answer
123 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) ...
PedroHerve's user avatar
2 votes
1 answer
1k 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 ...
kimliv's user avatar
  • 551
2 votes
2 answers
497 views

Turning a motor on and a led at the same time for a given time period

I need help with this code, I want to have a motor turn on for a given time and at the same time have an led light up to indicate it is on which will also turn of once the motor has stopped. It is ...
Alexanda Maryan's user avatar
2 votes
2 answers
630 views

How do you make an Arduino count down timer?

I want to make a countdown timer with a LilyPad Arduino for 3 seconds with red (1 second), then orange(1 second), then yellow (1 second), then green (3 seconds), all being triggered by a button. I ...
connor morrey's user avatar
2 votes
1 answer
347 views

Making an automated watering system with Arduino

I am trying to make an automated watering system using an Arduino. Here is my wiring diagram: And here is my circuit wired up: Here is the code that I'm using with Arduino. The code seems alright ...
James's user avatar
  • 21
2 votes
2 answers
140 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 ...
Stiglitz's user avatar
2 votes
1 answer
86 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 ...
Chris's user avatar
  • 51
2 votes
1 answer
291 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 ...
jaduuuui's user avatar
2 votes
2 answers
93 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 ...
lelilan's user avatar
  • 21
2 votes
2 answers
13k views

Arduino Mega 2560 interrupt pins and port mapping with rotary encoder

I am trying to use port manipulation in interrupts to read a rotary encoder. I found code for a Uno, so the port call for pins 2 and 3 are different. I think on the Mega they are PORTH3 and PORTH4 ...
kumquat's user avatar
  • 61
2 votes
1 answer
302 views

Is setting clock divider worth changing on delay() to save power?

Along all the "advanced" methods described in this article, does simple method as downscaling processor while delay makes a difference on power consumption? How much time does the clock alternation ...
madneon's user avatar
  • 225
2 votes
2 answers
723 views

Serial - Send data to Arduino while Arduino sending data

Arduino send data to PC each iteration. When I'm trying to send data to Arduino while receiving data from it, it takes too long. Serial.available() returns false even I sent data from PC. But if I add ...
bca's user avatar
  • 131
2 votes
1 answer
1k views

Results for GP2Y1010AU0F Dust Sensor

I am using Dust Sensor GP2Y1010AU0F I downloaded the code from the manufacturer here: http://www.waveshare.com/wiki/Dust_Sensor /**********************************************************************...
Daniel Benedykt's user avatar
2 votes
0 answers
57 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 ...
Chris H's user avatar
  • 146
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> ...
user71373's user avatar
2 votes
0 answers
150 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() { ...
Amy's user avatar
  • 21
2 votes
0 answers
393 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 ...
Syfian Bukhari's user avatar
2 votes
0 answers
131 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 ...
miles's user avatar
  • 21
2 votes
0 answers
2k views

Sending data from webserver to Arduino

Hello Arduino enthusiasts! I've been working on a keypad lock system for school lately and I need some advice.Basically, my code checks if the entered passcode is the same than a predefined passcode ...
Arxkz's user avatar
  • 23
2 votes
0 answers
318 views

Motor shield code [closed]

I am working on a project using an Arduino Uno and a motor driver shield to move a car with an IRremote. But the vehicle is only moving forward and backward. I want it to move left and right. Kindly ...
Swathi M's user avatar
2 votes
2 answers
774 views

Problem with measuring vibrations (Arduino UNO + step motor + accelerometer)

I'm trying to measure vibrations of the motor's shaft that is oscillating due to an eccentric load. For that, I am using the MPU 6050 6 axis accelerometer. The motor is a NEMA 17 stepper, connected to ...
mcluka's user avatar
  • 21
2 votes
0 answers
2k views

Arduino Uno doesn't work as Manchester code receiver

I'm sending some data from ATTINY85 to Arduino UNO using 433Mhz modules. Coding is Manchester using Manchester.h library from here. Transmitting data works perfectly, 433 receiver gets data alright. ...
Em Ka's user avatar
  • 151
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....
Akshay's user avatar
  • 11
1 vote
3 answers
2k 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. ...
Keltari's user avatar
  • 163
1 vote
2 answers
349 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^...
user-2147482637's user avatar
1 vote
3 answers
2k views

Arduino Uno "if" statement is ignored in code and halts execution when using Serial.ReadString()

I'm having a weird issue with my Uno trying to power on a PWM fan using a MOSFET. I'm setting a simple power on/off code using commands sent over the Serial Monitor, and although this code worked ...
avc's user avatar
  • 23

1
2 3 4 5 6