0% found this document useful (0 votes)
92 views4 pages

Schematic Diagram & Code Bluetooth RC

This code defines an Arduino sketch that controls the movement of a robot with 4 motors using input from the serial monitor. It defines 4 input pins to control the motors, sets them to output mode in setup(), and enters a loop to read serial input and set the pin states to cause different movements - forward, backward, left, right - based on the character received, effectively controlling the robot remotely via serial input.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views4 pages

Schematic Diagram & Code Bluetooth RC

This code defines an Arduino sketch that controls the movement of a robot with 4 motors using input from the serial monitor. It defines 4 input pins to control the motors, sets them to output mode in setup(), and enters a loop to read serial input and set the pin states to cause different movements - forward, backward, left, right - based on the character received, effectively controlling the robot remotely via serial input.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

SCHEMATIC DIAGRAM

CODE
int IN1 = 13;
int IN2 = 12;
int IN3 = 11;
int IN4 = 10;
char val;

void setup()
{
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);

Serial.begin(9600);
}

void loop()
{
while (Serial.available() > 0)
{
val = Serial.read();
Serial.println(val);
}

if( val == 'F') // Forward


{
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
}
else if(val == 'B') // Backward
{
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
}

else if(val == 'L') //Left


{
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
}
else if(val == 'R') //Right
{
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
}

else if(val == 'S') //Stop


{
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
}
else if(val == 'I') //Forward Right
{
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
}
else if(val == 'J') //Backward Right
{
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
}
else if(val == 'G') //Forward Left
{
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
}
else if(val == 'H') //Backward Left
{
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
}
}

You might also like