Hi I am doing project on anti-theft and collision detection system for vehicles using Rfid number. So for that i want to start car after detecting valid rfid number. My system detects rfid number also prints “Happy Journey” as written in my program but my car dummy car i.e. remote controlled car doesn’t start. I am posting my code. Any suggestions will be appreciated.As a remote control I am using keypad.
CODE:-
if(Serial.available())
{
int count=0;
while(Serial.available() && count<12)
{
input[count]=Serial.read();
count++;
delay(500);
}
//compare received signal with stored signal
/* When the counter reaches 12 (the size of the ID) we stop and compare each value of the input to the corresponding stored value /
if(count == 12) //
{
count =0; // reset counter variable to 0
flag = 1;
/ Iterate through each value and compare till either the 12 values are all matching or till the first mismatch occurs /
while(count<12 && flag !=0)
{
if(input[count]==x[count])
flag = 1; // every time the values match, we set the flag variable to 1
else
flag= 0;
/ if the ID values don’t match, set flag variable to 0 and stop comparing by exiting the while loop /
count++; // increment i
}
}
if(flag == 1) // If flag variable is 1, then it means the tags match
{
// analogWrite(Arduno,255);
lcd.print(“Happy Journey”);
lcd.setCursor(0, 1);
analogWrite(Arduno,255);
Serial.print(“Happy Journey”);
char key = keypad.getKey();
if (key == ‘1’) {
digitalWrite(motorR1, HIGH); digitalWrite(motorR2, LOW);
digitalWrite(motorL1, HIGH); digitalWrite(motorL2, LOW);
Serial.print(“1”);
}
/Backward****/
//If state is equal with letter ‘B’, car will go backward
else if (key == ‘2’) {
digitalWrite(motorR1, LOW); digitalWrite(motorR2, HIGH);
digitalWrite(motorL1, LOW); digitalWrite(motorL2, HIGH);
Serial.print(“2”);
}
/Left**/
//If state is equal with letter ‘L’, wheels will turn left
else if (key == ‘3’) {
digitalWrite(motorR1, LOW); digitalWrite(motorR2, LOW);
digitalWrite(motorL1, HIGH); digitalWrite(motorL2, LOW);
Serial.print(“3”);
}
/Right**/
//If state is equal with letter ‘R’, wheels will turn right
else if (key == ‘4’) {
digitalWrite(motorR1, HIGH); digitalWrite(motorR2,LOW);
digitalWrite(motorL1, LOW); digitalWrite(motorL2, LOW);
Serial.print(“4”);
}
/Stop*****/
//If state is equal with letter ‘S’, stop the car
else if (key == ‘0’){
digitalWrite(motorR1, LOW); digitalWrite(motorR2, LOW);
digitalWrite(motorL1, LOW); digitalWrite(motorL2, LOW);
Serial.print(“0”);
}
// Enablepin==LOW; use when we want to enable and disable rfid reader
}
else
{
analogWrite(Arduno,0);
lcd.setCursor(0, 1);
lcd.print(“GET OUT”);
}
}