obstacle avoiding robot

Started by JOEL DEEPAK March 24, 2010
hello,
i wrote a code for *obstacle avoiding but *the motors(IM USING TWO DC GEAR
MOTORS ONLY) are not running properly....IM USING ATMEGA8 MICROCONTROLLER
...the code which i wrote is...

*CODE FOR OBSTACLE AVOIDING:*

> #define F_CPU 1000000UL
> #include
> #include
> #define forward 0xa0
> #define turnleft 0x60
> #define turnright 0x90
> #define obst_right PB0
> #define obst_left PB7
>
> void delay (unsigned char count)
> {
> while(count)
> {
> _delay_ms(1);
> count--;
> }
> }
>
> int main(void)
> {
> DDRB =0xff;
> DDRD =0x00;
> while(1)
> {
> if (obst_right==0)
> {
> PORTD =turnleft;
> _delay_ms(30);
> }
> if (obst_left==0)
> {
> PORTD =turnright;
> _delay_ms(30);
> }
> else
> {
> PORTD=forward;
> }
> }
> }
>
>
-* I M GIVING INPUTS FROM SENSORS(OBSTACLE AVOIDING) TO* *PB0 AND PB7 OF
ATMEGA8*
*- IM TAKING OUTPUTS FROM PD4,PD5,PD6,PD7 OF ATMEGA8*
*-PD4,PD5 ARE FOR ONE MOTOR AND PD6,PD7 ARE FOR ANOTHER*
*if somebody know how to rectify the above program so that motors should run
correctly can help...*