VIDEO
COMPONENTS AND SUPPLIES
ABOUT THIS PROJECT
I am fond of playing RC Boat when I was little. Now, I have the ability to make an unique Boat on my own. I gained a sense of achievement and entertainment in the process of making it.
Application:- Jrobot Controller
Contact us for support
//Arduino Code//
// 2020/1/3 adapted by Zach
int outPin1 = 5 ; //motor1
int outPin2 = 6 ; //motor1
int outPin3 = 10 ; //motor2
int outPin4 = 11 ; //motor2
int red = 2 ;
int white = 3 ;
char bt = 0 ; //BT
void setup ()
{
Serial . begin ( 9600 );
pinMode ( outPin1 , OUTPUT );
pinMode ( outPin2 , OUTPUT );
pinMode ( outPin3 , OUTPUT );
pinMode ( outPin4 , OUTPUT );
pinMode ( red , OUTPUT );
pinMode ( white , OUTPUT );
}
void loop ()
{
if ( Serial . available () > 0 ) //save incoming data to variable 'bt'
{
bt = Serial . read ();
digitalWrite ( white , HIGH );
if ( bt == 'F' ) //move forwards
{
digitalWrite ( outPin1 , HIGH );
digitalWrite ( outPin2 , LOW );
digitalWrite ( outPin3 , LOW );
digitalWrite ( outPin4 , LOW );
digitalWrite ( red , LOW );
}
else if ( bt == 'B' ) //move backwards
{
digitalWrite ( outPin1 , LOW );
digitalWrite ( outPin2 , HIGH );
digitalWrite ( outPin3 , LOW );
digitalWrite ( outPin4 , LOW );
digitalWrite ( red , HIGH );
}
else if ( bt == 'S' ) //stop!!
{
digitalWrite ( outPin1 , LOW );
digitalWrite ( outPin2 , LOW );
digitalWrite ( outPin3 , LOW );
digitalWrite ( outPin4 , LOW );
digitalWrite ( red , LOW );
}
else if ( bt == 'R' ) // turn wheels right
{
digitalWrite ( outPin3 , LOW );
digitalWrite ( outPin4 , HIGH );
digitalWrite ( outPin1 , LOW );
digitalWrite ( outPin2 , LOW );
digitalWrite ( red , LOW );
}
else if ( bt == 'L' ) //turn wheels left
{
digitalWrite ( outPin3 , HIGH );
digitalWrite ( outPin4 , LOW );
digitalWrite ( outPin1 , LOW );
digitalWrite ( outPin2 , LOW );
digitalWrite ( red , LOW );
}
else if ( bt == 'G' ) //move forward left
{
digitalWrite ( outPin1 , HIGH );
digitalWrite ( outPin2 , LOW );
digitalWrite ( outPin3 , HIGH );
digitalWrite ( outPin4 , LOW );
digitalWrite ( red , LOW );
}
else if ( bt == 'I' ) //move forward right
{
digitalWrite ( outPin1 , HIGH );
digitalWrite ( outPin2 , LOW );
digitalWrite ( outPin3 , LOW );
digitalWrite ( outPin4 , HIGH );
digitalWrite ( red , LOW );
}
else if ( bt == 'H' ) //move backward left
{
digitalWrite ( outPin1 , LOW );
digitalWrite ( outPin2 , HIGH );
digitalWrite ( outPin3 , HIGH );
digitalWrite ( outPin4 , LOW );
digitalWrite ( red , LOW );
}
else if ( bt == 'J' ) //move backward right
{
digitalWrite ( outPin1 , LOW );
digitalWrite ( outPin2 , HIGH );
digitalWrite ( outPin3 , LOW );
digitalWrite ( outPin4 , HIGH );
digitalWrite ( red , LOW );
}
}
} //Project Diagram//
Comments