Hi, i need code for my obstacle detection robot , i use 2 IR sensors & i wrote code for it but its not wrkng i think , i am inserting my code plzzz do tell me wats wrong and if so pl z suggest me ,i am new to it
#include<avr\io.h>
#include<util\delay.h>
int main()
{
DDRB=0xff; //port B for motor as output
PORTB=0x00;
DDRC=0xfc; //port c last 2 pins for sensors inputs
while(1)
{
if((PINC&0x01)==0&&(PINC&0x02)==1) //1st sensor ON & 2nd sensor OFF
{
PORTB=0x03; //move right direction
_delay_ms(1000);
}
if((PINC&0x01)==0&&(PINC&0x02)==0) //1st & 2nd both are ON
{
PORTB=0x03; //default move right direction
_delay_ms(1000);
}
if((PINC&0x01)==1&&(PINC&0x02)==0) //1st sensor OFF & 2nd sensor ON
{
PORTB=0x14; //move left direction
_delay_ms(1000);
}
if((PINC&0x01)==1&&(PINC&0x02)==1) //both sensor are OFF
{
PORTB=0x17; //moves forward
_delay_ms(1000);
}
}
}
for this i used ROBOT CONTROLLER M1 ,