RF controlled car making in tamil
coding
void setup() {pinMode(2,OUTPUT); // in1
pinMode(3,OUTPUT); // in2
pinMode(4,OUTPUT); // in3
pinMode(5,OUTPUT); // in4
pinMode(7,INPUT); // RF in1
pinMode(8,INPUT); // RF in2
pinMode(9,INPUT); // RF in3
pinMode(10,INPUT); // RF in4
Serial.begin(9600);
}
void loop() {
int RF1, RF2, RF3, RF4;
RF1 = digitalRead(7);
RF2 = digitalRead(8);
RF3 = digitalRead(9);
RF4 = digitalRead(10);
if(RF1) //forward
{
digitalWrite(2,HIGH);
digitalWrite(3,LOW);
digitalWrite(4,HIGH);
digitalWrite(5,LOW);
Serial.println("0");
}
if(RF2) //backward
{
digitalWrite(2,LOW);
digitalWrite(3,HIGH);
digitalWrite(4,LOW);
digitalWrite(5,HIGH);
Serial.println("1");
}
if(RF3) //right
{
digitalWrite(2,HIGH);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,HIGH);
Serial.println("2");
}
if(RF4)//left
{
digitalWrite(2,LOW);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,LOW);
Serial.println("3");
}
else
{
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
Serial.println("3");
}
}
Comments
Post a Comment