Hey guys, this is my first time using Arduino forums so if I'm doing some mistakes or posting in a wrong section please forgive me. Anyways, I want some help regarding my project. I'm trying to build a car using IR sensor which has a 16*2 LCD display. To test the project I used LEDs since I was not able find geared 5V DC motors, it was working as I wished it to. Later when I found my motors I hooked them up as I hoked up my LEDs previously but once I use my remote to use my car it doesn't work, it is almost like it freezes.
Here is the code:
// Setting up LCD Display Here.
#include<LiquidCrystal.h>
int RS = 12;
int E = 11;
int D4 = 5;
int D5 = 4;
int D6 = 3;
int D7 = 2;
LiquidCrystal lcd(RS,E,D4,D5,D6,D7);
// Setting up IR reciver sensor here.
#include<IRremote.h>
int IR_Reciver_Pin = 9;
IRrecv irrecv(IR_Reciver_Pin);
decode_results results;
// Setting up DC motor pins.
int MotorOne = 6;
int MotorTwo = 7;
// Setting up other variables required.
String S1 = "Welcome!";
String S2 = "Rollin forward ";
String S3 = "captain!";
String S4 = "Turning towards ";
String S5 = "right.";
String S6 = "left.";
String S7 = "Halting Captain!";
void setup() {
// Initiating LCD display here.
lcd.begin(16,2);
lcd.print(S1);
// Initiating IR reciver sensor here.
irrecv.enableIRIn();
// Initiating DC motors.
pinMode(MotorOne,OUTPUT);
pinMode(MotorTwo,OUTPUT);
//initiating Serial Monitor.
Serial.begin(9600);
}
void loop() {
// Reading IR remote value.
if(irrecv.decode(&results))
{
int value = results.value;
Serial.print("CODE: ");
Serial.println(results.value);
irrecv.resume();
}
// Code for going forward.
if(results.value==3772778233)
{
lcd.clear();
lcd.print(S2);
lcd.setCursor(0,2);
lcd.print(S3);
digitalWrite(MotorOne,HIGH);
digitalWrite(MotorTwo,HIGH);
}
// Code for turning right.
if(results.value==3772794553)
{
lcd.clear();
lcd.print(S4);
lcd.setCursor(0,2);
lcd.print(S5);
digitalWrite(MotorOne,HIGH);
digitalWrite(MotorTwo,LOW);
}
// Code for turning left.
if(results.value==3772819033)
{
lcd.clear();
lcd.print(S4);
lcd.setCursor(0,2);
lcd.print(S6);
digitalWrite(MotorOne,LOW);
digitalWrite(MotorTwo,HIGH);
}
// Code for stoping.
if(results.value==3772782313)
{
lcd.clear();
lcd.print(S7);
digitalWrite(MotorOne,LOW);
digitalWrite(MotorTwo,LOW);
}
}
Please help me if you are seeing this,