Home » Sometech » line follower robot

line follower robot

line follower robot

#include
void main()
{
DDRC=0b0000000; //set PORTC as input port
DDRB=0b00011110; //PB1, PB2, PB3, PB4 as output port
int LS=0, RS=0; // define & initialize ls, RS integer as 0 to
// acquire the left sensor status in LS and right sensor
// status in RS
while(1) // create infinite loop
{
LS=(PINC&0b0000001); //acquire only left sensor status connected at PC0
RS=(PINC&0b0001000); // acquire only right sensor status connected at PC3
if((LS==0b0000000)&(RS==0b0000000)) //check sensor status for both sensor OFF
{
PORTB=0b00000000; //stop
LS=0; //set sensor status off
RS=0; //set sensor status off
}
if((LS==0b0000001)&(RS==0b0000000)) //check sensor status for left sensor=ON and
// right sensor=OFF
{
PORTB=0b00010000; //turn right
LS=0; //set sensor status off
RS=0; //set sensor status off
}
if((LS==0b0000000)&(RS==0b0001000)) //check sensor status for left sensor=OFF and
// right sensor=ON
{
PORTB=0b00000010; //turn left
LS=0; //set sensor status off
RS=0; //set sensor status off
}
if((LS==0b0000001)&(RS==0b0001000)) //check sensor status for both sensor ON
{
PORTB=0b00010010; //move forward
LS=0; //set sensor status off
RS=0; //set sensor status off
}
}
}

Advertisements

SoME Tech

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

%d bloggers like this: