Consider:
#include <avr/io.h>
int main(void)
{
DDRB = 0b11111111; // PORTB as output port connected to motors;
DDRC = 0b0000000; // PORTC Input port connected to sensors;
int left_sensor = 0;
int right_sensor = 0;
while(1)
{
left_sensor = PINC&0b00000001;
right_sensor = PINC&0b00001000;
if((left_sensor==0b0000000) && (right_sensor==0b0000000))
{
PORTB = 0b00000000;
}
else if((left_sensor==0b00000001) && (right_sensor==0b00001000))
{
PORTB = 0b00010010;
}
else if((left_sensor==0b0000000) && (right_sensor==0b0001000))
{
PORTB = 0b00000010;
}
else if((left_sensor==0b00000001) && (right_sensor==0b0000000))
{
PORTB = 0b00010000;
}
}
}
It's showing "expected expression before while". I have tried everything, but I am not getting any solution to it.
Error:
Expected Expression before 'while'
Compiler: Atmel Studio 7