Hi,
I have been making a remote control tank with a cheap IR remote.
I have built the circuit and finished the code and everything worked in testing.
When I went to go put everything together the IR remote stopped working
Things I have tried -
-Changing IR pin
-Printing value in Serial Monitor (which there was none)
-Changing 5v and GND pins
When I press the remote the receiver light blinks but no value seen in Serial monitor.
Here is my code if It helps.
This is my first Arduino project and it was going great until this
Thanks,
//Libraries
#include <IRremote.h> //must copy IRremote library to arduino libraries
#include <Servo.h>
#define plus 0xFFB04F //clockwise rotation button
#define minus 0xFF6897 //counter clockwise rotation button
#define Foward 0xFF629D
#define Backward 0xFFA857
#define Left 0xFF22DD
#define Right 0xFFC23D
#define Stop 0xFF02FD
#define Shoot 0xFF9867
#define ShootOff 0xFF18E7
//MOTOR 1=LEFT
//MOTOR 2=RIGHT
int RECV_PIN = 12; //IR receiver pin
Servo servo;
int val; //rotation angle
bool cwRotation, ccwRotation; //the states of rotation
IRrecv irrecv(RECV_PIN);
decode_results results;
int speakerPin = 13; //Assign Speaker Pin
int motorPin1a = 10; //Assign Motor Pins
int motorPin1b = 8; //Assign Motor Pins
int motorPin2a = 9; //Assign Motor Pins
int motorPin2b = 7; //Assign Motor Pins
int laserPin = 2; //Assign Laser Pin
int lightPin = A5; //Assign LDR Pin
//Setup
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
servo.attach(3); //servo pin
pinMode(speakerPin, OUTPUT); //Set pin to Output
pinMode(motorPin1a, OUTPUT); //Set pin to Output
pinMode(motorPin1b, OUTPUT); //Set pin to Output
pinMode(motorPin2a, OUTPUT); //Set pin to Output
pinMode(motorPin2b, OUTPUT); //Set pin to Output
pinMode(laserPin, OUTPUT); //Set pin to Output
pinMode(lightPin, INPUT); //Set pin to Input
}
void loop()
{
int light = analogRead(lightPin);
// Serial.println(light);
if (light < 80)
{
Serial.println(light);
digitalWrite(motorPin1a, LOW);
digitalWrite(motorPin1b, LOW);
digitalWrite(motorPin2a, LOW);
digitalWrite(motorPin2b, LOW);
delay(2000);
}
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
//-------------------Servo----------------------------------------------------------------
if (results.value == plus)
{
cwRotation = !cwRotation;
ccwRotation = false;
}
if (results.value == minus)
{
ccwRotation = !ccwRotation;
cwRotation = false;
}
}
if (cwRotation && (val != 175)) {
val++;
}
if (ccwRotation && (val != 0)) {
val--;
}
servo.write(val);
delay(5); //General speed
//-------------------Motor----------------------------------------------------------------
if (results.value == Foward)
{
digitalWrite(motorPin1a, LOW);
digitalWrite(motorPin1b, HIGH);
digitalWrite(motorPin2a, HIGH);
digitalWrite(motorPin2b, LOW);
}
if (results.value == Backward)
{
digitalWrite(motorPin1a, HIGH);
digitalWrite(motorPin1b, LOW);
digitalWrite(motorPin2a, LOW);
digitalWrite(motorPin2b, HIGH);
}
if (results.value == Left)
{
digitalWrite(motorPin1a, HIGH);
digitalWrite(motorPin1b, LOW);
digitalWrite(motorPin2a, HIGH);
digitalWrite(motorPin2b, LOW);
}
if (results.value == Right)
{
digitalWrite(motorPin1a, LOW);
digitalWrite(motorPin1b, HIGH);
digitalWrite(motorPin2a, LOW);
digitalWrite(motorPin2b, HIGH);
}
if (results.value == Stop)
{
digitalWrite(motorPin1a, LOW);
digitalWrite(motorPin1b, LOW);
digitalWrite(motorPin2a, LOW);
digitalWrite(motorPin2b, LOW);
}
if (results.value == Shoot)
{
digitalWrite(laserPin, HIGH);
digitalWrite(speakerPin,HIGH);
delay(2000);
}
if (results.value == ShootOff)
{
digitalWrite(laserPin, LOW);
digitalWrite(speakerPin,LOW);
}
}
Edit
Here is my circuit on 123d Circuits.