RC car(wired) using 8051

in this tutorial we'll be working on rc car that is connected directly from your car to be operated to remote through wire. remote having four switches used to customize four different modes of operation i.e moving forward,reverse,turning right,turning left. in this model four wheels are connected with chassis out of which two are required to operate through dc motor  before proceeding further it is assumed that you have basic knowledge of LCD.

Proteus Design

in this design four switches are connected  to pins of port 1 and motors are connected to pins of port 3  via L293D. lcd is used to display current status system.

CODE

by pressing switch 1 you make both motors to move forward. similarly by plunging switch 2 you would reverse the polarity of both the motors by doing so you actually make motors to rotate in opposite direction

                                                     

                                          

To turn your vehicle you can choose either of these two method a)to turn right by keeping right motor in standstill state while rotating the left one. similarly, take left by providing power only to right of two motors. b)to take right shift rotate the left motor in clockwise direction and right motor in anticlockwise direction.similarly,to turn left rotate the left motor in anticlockwise direction and right motor in clockwise direction in this program first one is being used.

complete code

#include<reg51.h>
#define lcdport P2
sbit rs=P3^4;
sbit en=P3^6;
sbit rw=P3^5;
sbit sw1=P1^0;
sbit sw2=P1^1;
sbit sw3=P1^2;
sbit sw4=P1^3;
sbit m1a=P3^0;
sbit m1b=P3^1;// motor 1
sbit m2a=P3^2;
sbit m2b=P3^3;// motor 2
void lcdcmd(char);
void lcdint();
void lcddata(char);
void lcdstring(char *);
void delay(unsigned int);

void main()
{
lcdport=0x00;
P1=0x00;
P3=0x00;
lcdint(); 
   delay(500);
   lcdstring("press 1 to move");
        lcdcmd(0xc0);
   lcdstring("forward...");
   delay(50000);
   lcdcmd(0x01);
   lcdcmd(0x02);
   lcdstring("press 2 to move");
    lcdcmd(0xc0);
   lcdstring("reverse...");
   delay(50000);
   lcdcmd(0x01);
   lcdcmd(0x02);
   lcdstring("press 3 to turn");
   lcdcmd(0xc0);
   lcdstring("right...");
   delay(50000);
   lcdcmd(0x01);
   lcdcmd(0x02);
   lcdstring("press 4 to turn");
   lcdcmd(0xc0);
   lcdstring("left...");
   delay(50000);
   lcdcmd(0x01);
   lcdcmd(0x02);
  while(1)
  {
  if(sw1==1)
   {
   m1a=1;
   m1b=0;
   m2a=0;
   m2b=1;
    lcdstring("moving forward...");
    delay(500000);
    lcdcmd(0x01);
   }
   if(sw2==1)
   {
   m1a=0;
   m1b=1;      
   m2a=1;
   m2b=0;
    lcdstring("moving reverse...");
    delay(500000);
    lcdcmd(0x01);
   }
   if(sw3==1)
   {
   m1a=0;
   m1b=0;
   m2a=0;
   m2b=1;
    lcdstring("turning right...");
    delay(500000);
    lcdcmd(0x01);
   }
   if(sw4==1)
   {
   m1a=1;
   m1b=0;
   m2a=0;
   m2b=0;
    lcdstring("turning left...");
    delay(500000);
    lcdcmd(0x01);
   }
     }
}
 void delay(unsigned int x)
{
 unsigned int i;
 for(i=0;i<x;i++);
}
void lcdint()
{
  lcdcmd(0x38);
  delay(500);
  lcdcmd(0x01);
  delay(500);
  lcdcmd(0x0c);
  delay(500);
  lcdcmd(0x80);
  delay(500);
  lcdcmd(0x0e);
  delay(500);
}
void lcdcmd(char value)
{
  lcdport = value;
  rw=0;
  rs=0;
  en=1;
  delay(500);
  en=0;
}
void lcdstring(char *p)
{
  while(*p!='\0')
   {
     lcddata(*p);
     delay(2000);
     p++;
   }
}
void lcddata(char value)
{
  lcdport = value;
  rs=1;
  rw=0;
  en=1; 
  delay(500);
  en=0;
}

Video

Category: 

tags: 

Share

Who's new

  • ravirajpatil871...
  • shubhambajoria
  • yassir
  • demiholyman890954
  • scottgillum51169040

Get Notified

 

Share

We are Social

Syndicate

Subscribe to Syndicate