int state;
const int in1 = 7;
const int in2 = 6;
const int in3 = 4;
const int in4 = 5;
void setup()
{
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4,OUTPUT);
Serial.begin(9600); // Baud rate set to 9600bps
}
void loop() {
if(Serial.available() > 0)
{
state = (char)Serial.read();
}
if (state == '1')
{
Serial.println("A");
digitalWrite(in1, HIGH);
digitalWrite(in3, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in4, LOW);
}
if (state == '2')
{
Serial.println("B");
digitalWrite(in1, LOW);
digitalWrite(in3, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in4, HIGH);
}
if (state == '3')
{
Serial.println("C");
digitalWrite(in3, LOW);
digitalWrite(in1, HIGH);
}
if(state =='4')
{
Serial.println("D");
digitalWrite(in2, LOW);
digitalWrite(in4, HIGH);
}
if (state=='5')
{
Serial.println("HERE");
digitalWrite(in1, LOW);
digitalWrite(in3, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in4, HIGH);
}
}
I am making a rc car that will have a remote control on my phone that i have made using mit app inventor.........evey connection was perfect and the car was running perfectly......but after I came from having dinner and switched it on it refused to work anymore.....The char vakues sent from the app is not getting received by the arduino nano.......but works fine when i enter the characters in the serial monitor......what kind of problem is this please help
Button 1=UpButton
Button 6=DownButton
Button 3=LeftButton
Button 4=RightButton