08-17-2017, 12:07 AM
PROGRAM FOR WALL FOLLOWER.
#include<avr/io.h> // For ATMega8
int main(void)
{
DDRC=0x00; // set PORTC as input port
DDRB=0x0F; // PB0, PB1, PB2, PB3 as output port for motor
int Right_sensor=0;
while(1) // infinite loop
{
Right_sensor=(PINC&0x01); //sensor status connected at PC0
if(Right_sensor==0x00) //right sensor OFF
{
PORTB=0x08; //right turn
}
else
PORTB=0x01; //left turn
}
}