Wireless Robo-car Using 360° Servo Motor

Introduction: Wireless Robo-car Using 360° Servo Motor

About: embedded system enthusiast ...

smart car robot using 360 Degree continuous rotation servo motor.

Step 1: Components

Step 2: Making Steps

Step 3: Prototype

Step 4: Wireless Communication System -zigbee

Step 5: Program

#include <Servo.h>

///////////////////////////// KEYS /////////////////////////////
#define FWD_KEY     'W'
#define BWD_KEY     'S' 
#define QUICK_L_KEY 'Q'
#define QUICK_R_KEY 'E' 
#define TRNL_L_KEY  'A' 
#define TRNL_R_KEY  'D'
#define STOP_KEY    ' '
#define KEY_DLY     200
///////////////////////////////////////////////////////////////////
#define STOP_L 95 
#define STOP_R 95 

#define FWD_L 0 
#define FWD_R 360 

#define BWD_L 180
#define BWD_R 0 

#define QTRNL_L STOP_L+5 
#define QTRNL_R FWD_R 

#define QTRNR_L FWD_L 
#define QTRNR_R STOP_R-5 

#define TRNL_L STOP_L 
#define TRNL_R FWD_R 

#define TRNR_L FWD_L 
#define TRNR_R STOP_R

/////////////////////////////////////////////////////////////////////

Servo left_servo,right_servo;  // create servo object to control a servo
unsigned char incomingByte=0;
unsigned int count=0;


int potpin = 0;  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin

void setup()
{
   Serial.begin(9600);
  left_servo.attach(2);  // attaches the servo on pin 9 to the servo object
  right_servo.attach(3);  // attaches the servo on pin 10 to the servo object
  left_servo.write(STOP_L);
  right_servo.write(STOP_R);
}

void loop()
{

   if(Serial.available() > 0)
   {
     incomingByte =Serial.read();
   }

   if(incomingByte==FWD_KEY)
  {
    left_servo.write(FWD_L);
right_servo.write(FWD_R);
incomingByte='X';
        count=0;
  }
  else if(incomingByte==BWD_KEY)
  {
    left_servo.write(BWD_L);
right_servo.write(BWD_R); 
incomingByte='X';
        count=0;
  }
  else if(incomingByte==QUICK_L_KEY)
  {
    left_servo.write(QTRNL_L);
right_servo.write(QTRNL_R);
    incomingByte='X';
    count=0;
  }
  else if(incomingByte==QUICK_R_KEY)
  {
    left_servo.write(QTRNR_L);
right_servo.write(QTRNR_L);
    incomingByte='X';
    count=0;
  }
    else if(incomingByte==TRNL_L_KEY)
  {
    left_servo.write(TRNL_L);
right_servo.write(TRNL_R);
    incomingByte='X';
    count=0;
  }
  else if(incomingByte==TRNL_R_KEY)
  {
    left_servo.write(TRNR_L);
right_servo.write(TRNR_R);
    incomingByte='X';
    count=0;
  }
   else if(incomingByte==STOP_KEY)
  {
    left_servo.write(STOP_L);
right_servo.write(STOP_R);
    incomingByte=0;
    count=0;
  }
else if(incomingByte=='X')
{
    if(++count>KEY_DLY)
{
left_servo.write(STOP_L);
right_servo.write(STOP_R);
count=0; incomingByte=0;
}
     delay(1);
}

}

Step 6: Videos

Step 7: Robo Car Using PIC16F877A

Full Spectrum Laser Contest

Participated in the
Full Spectrum Laser Contest

Robot Contest

Participated in the
Robot Contest

Arduino Contest

Participated in the
Arduino Contest

Be the First to Share

    Recommendations

    • The 1000th Contest

      The 1000th Contest
    • Battery Powered Contest

      Battery Powered Contest
    • Hand Tools Only Challenge

      Hand Tools Only Challenge

    Discussions