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
1
vote
2answers
639 views

code optimazation 6x6 Matrix

I planed a 6x6 matrix with a Arduino Nano as controller. Its only possible to let one LED in the matrix lighten up. Any idea how I get the Code smaller? (Im a C Noobie ^^) ~Nico Circuit diagram: ...
0
votes
1answer
659 views

ColorPal Sensor

First off let me preface this my explaining my background. I am a mechanical engineering student and have some programming knowledge but it's limited. I'm trying to make a skittle sorter and I right ...
1
vote
2answers
561 views

Arduino whack-a-mole game not working

Everyone, I am new to this. Currently I am trying to make a Whack-a-mole game for my school project. There will be a total of 6 moles (corresponding to 6 LEDs, which will light up randomly). At each ...
-1
votes
1answer
215 views

autoCalibrateAccelerometerOffset() Why does my Z values swing from 0 to 1g in static condition?

I tried to implement the autoCalibrateAccelerometerOffset() function, through the code below on Arduino Genuino 101. In a static test, without any stress or noise, I read the three axis value. ...
0
votes
2answers
745 views

Is this example for playing music without delay correct?

I've followed the directions from this answer, to try and play music without delay. This is my code so far: #include "pitches.h" int melody[] = { NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 0, ...
0
votes
1answer
106 views

Bot not activating after button press

This bot is supposed to begin moving forward when the button is pressed, and stop after counting 3 lines of tape on the ground. Currently it is set up to scan the color of the floor at the beginning ...
0
votes
1answer
114 views

Help combining code

Can someone please help me fix my code? Basically, a user inputs values that determine how many beeps will play from a breadboard-compatible speaker, and right after the beeps are played, a motor (...
0
votes
2answers
3k views

Start/Stop/Reset the melody using buttons

I have 2 buttons. Button 1 will start/stop the melody while the button 2 will reset the melody. My melody is "Happy Birthday". How am I going to use the buttons to start/stop/reset the melody? Here'...
0
votes
1answer
7k views

What is the difference between a 3 pin and 4 pin ultrasonic range sensor?

I am following a tutorial that uses an arduino and ultrasonic range sensor, it calls for a 3 pin module (Paralax 28015-ND) and I have a 4 pin module (http://www.electroschematics.com/wp-content/...
0
votes
1answer
88 views

Confusion on array definition at Arduino website

See the below explanation about Arrays from Arduino's official site: Creating (Declaring) an Array All of the methods below are valid ways to create (declare) an array. int myInts[6]; int ...
4
votes
1answer
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;...
2
votes
1answer
293 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 ...
1
vote
2answers
590 views

How do I add dimming control to my following LED toggling program on Arduino? Also how do I improve my existing code?

I am attaching my code below : int cwled=9; int wwled=10; int button=8; int buttonpress; long startTime=0; long endTime; long holdTime; boolean previous = LOW; boolean current; int state=0; int pot = ...
2
votes
2answers
683 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 ...
3
votes
1answer
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 ...
2
votes
3answers
446 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() { ...
0
votes
2answers
234 views

Print when echo is read by HR-S04 sensor

I'm trying to see when an echo is received by my HR-S04 sensor. I have a Serial.println within my while loop to read the signal and see once a change happens to break the loop. The issue is my serial ...
0
votes
5answers
329 views

Serial Monitor "button" implementation

I have a small project and I have some problems while working on that. The idea of the project is as below: I have an LED which is operated by two "buttons". The buttons takes two values (1 or0) which ...
0
votes
2answers
305 views

neopixel not blinking

I have some neopixels, and I have one hooked up to my teensy. I want to have the color change, when the push button is pressed vs not pressed. The LED will change colour when I upload the code, if I ...
2
votes
1answer
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 /**********************************************************************...
-2
votes
1answer
40 views

I need to power some coils sequentially, can someone help me with the code?

int coilSetOne = 0; int coilSetTwo = 1; int coilSetThree = 2; int coilSetFour = 3; int switchInput = 4; void setup() { pinMode(coilSetOne, OUTPUT); pinMode(coilSetTwo, OUTPUT); pinMode(...
1
vote
1answer
660 views

Sending data via SoftwareSerial results in garbled reception

My overall goal is to have an Arduino Uno with an Ethernet Shield send a short (5-character) string via a SoftwareSerial connection and a UDP packet when I press a button. The device which is ...
-1
votes
1answer
655 views

How to properly receive data from accelerometer @ arduino in processing and map it?

I'm busy making a project where my accelerometer @arduino can controle a ellipse @processing But the problem is, it doesn't work. With the code I have now, I can receive the data from the ...
0
votes
1answer
45 views

What's up with my code?

Sorry if my code isn't well written or anything because I'm new to Arduino and coding in C, but what is wrong with my code? int sidepin = 2; int LED = 5; int val; void setup() { pinMode(sidepin, ...
1
vote
1answer
683 views

Why doesn't my 1602A LCD display text with this code?

#include <SPI.h> #include <MFRC522.h> #include <LiquidCrystal.h> #include <Servo.h> #define RST_PIN 9 // Configurable, see typical pin layout above #define SS_PIN 10 // ...
0
votes
1answer
1k views

Button Relay Control

How can I fix this sketch to make it so that once the button is pressed, it performs some action for a certain amount of time and then returns back to a low state until it is pressed again. For ...
1
vote
1answer
9k views

MPU6050 code explanation

I'm new to arduino and electronics. I've been trying to use the MPU6050 with my arduino but I'm having difficulty understanding the code. I'm referring to the code put up on the arduino website (http:/...
5
votes
2answers
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; ...
0
votes
1answer
170 views

Strings that always stay empty

I wrote an app that listens on the network for command over UDP and sends back an answer. Whatever I try to put into my answer never get sent. The string is always empty. The following code prints a ...
0
votes
2answers
1k views

"Return" Code Not Working

I'm trying to experiment with a "return" function. Yet each time I try to run my program, there happens to be an error, like "expected declaration before '}' token." Can someone explain the basics of ...
11
votes
1answer
243 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(...
3
votes
5answers
12k 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 ...
2
votes
1answer
209 views

Quick Programming Check/Review

I've been racking my head trying to start programming in a library organized method. My code works, but the translation and split to a .h and .cpp file is riddled with errors. It's gotta be stupidly ...
0
votes
2answers
11k views

Failed to read DHT22 sensor using Arduino Uno

why do I end up with the display "Failed to read from DHT sensor!" in the serial monitor in most cases when I run the code given below?? In case I reduce the delay to 1000ms the reading shows 0.00 for ...
0
votes
3answers
2k views

Pair of nRF24L01s ping/pong example sketch works, but using my own code fails after first successful transmit

I have a pair of nRF24L01s connected to a pair of Arduino Unos and I'm using the RF24 library from here: RF24 library. When I run the pingpair example sketch, the radios transmit and receive back and ...
1
vote
1answer
2k views

Arduino CC3000 websocket client

I am working for arduino websocket client with CC3000 wifi board from adafruit. I have usde this websocket example as a reference and modified to work with cc3000 wifi board. I am not able to connect ...

1 2 3 4
5