robot032
Newbie level 1
Autonomous Mobile Robot
hi, i want to make autonomous mobile robot will send signal from atmega16 uc to servo motor according to signal coming from infrared sensor, if sensor detect obstacle the Robot will send signal to servo motors to avoid obstacle ,Robot in same time will send signal to computer via RF module to drawing path
but i have problem simulation is work very will, but in practical the Robot does not work as I want..
Note:
am use code vision AVR
and protus7
i am sorry for bad language.
happy new year
sami
hi, i want to make autonomous mobile robot will send signal from atmega16 uc to servo motor according to signal coming from infrared sensor, if sensor detect obstacle the Robot will send signal to servo motors to avoid obstacle ,Robot in same time will send signal to computer via RF module to drawing path
Code:
while (1)
{
// Place your code here
int forward=0x00;
int left_P=0x01;
int left=0x02;
int Right=0x03;
int back=0x04;
bit x;
unsigned int counter;
if (TIFR==0x01)
counter++;
while(read_adc(0x00) < 127) //if the sensor not detect object-----------------------------
{
//printf("Forward");
PORTC=0x05; //go forward
}
x=0;
while(read_adc(0x00) >= 127) //if the sensor detect object---------------------------------
{
/*if the main sensor read object .so, go to two Edge Sensor
-----------------------------------------------------
left sensor | Right sensor | state
-----------------------------------------------------
0 | 0 | go left(priroty)
0 | 1 | go left 90 degree
1 | 0 | go Right 90 degree
1 | 1 | go left 180 degree
in all previous cases the main sensor value is 1 .
*/
//----------------------------------------------------------
if (PINB==0x00) //if both edge sensor not
{
if(x==0)
{
TCCR0=0x03; //start timer
PORTC=0x09; //go to left
}
delay_ms(1);
counter++; //if the over flow occur the 'countr' variable increase by 1
x=1;
//printf("%x",left_P);
if (counter>5000) //if access to 5000 overflow means the robot rotate to left
{
PORTC=0x00; //stop
TCCR0=0x00; //then stop timer
counter=0; //zeros the variable counter
}
}
//-------------------------------------------------------------
if (PINB==0x01)
{
if(x==0)
{
TCCR0=0x03; //start timer
PORTC=0x09; //go to left
}
delay_ms(1);
counter++; //if the over flow occur the 'countr' variable increase by 1
x=1;
//printf("%x",left);
if (counter>5000) //if access to 5000 overflow means the robot rotate to left
{
PORTC=0x00; //stop
TCCR0=0x00; //then stop timer
counter=0; //zeros the variable counter
}
}
//-------------------------------------------------------------
if (PINB==0x02)
{
if(x==0)
{
TCCR0=0x03; //start timer
PORTC=0x06; //go to Right
}
delay_ms(1);
counter++; //if the over flow occur the 'countr' variable increase by 1
x=1;
//printf("%x",Right);
if (counter>5000) //if access to 5000 overflow means the robot rotate to left
{
PORTC=0x00; //stop
TCCR0=0x00; //then stop timer
counter=0; //zeros the variable counter
}
}
//-------------------------------------------------------------
if (PINB==0x03) //if the two Edge sensor detect
{
if(x==0)
{
TCCR0=0x03; //start timer
PORTC=0x09; //go to left 180 degree
}
delay_ms(1);
counter++; //if the over flow occur the 'countr' variable increase by 1
x=1;
//printf("%x",back);
if (counter>10000) //if access to 5000 overflow means the robot rotate to left
{
PORTC=0x00; //stop
TCCR0=0x00; //then stop timer
counter=0; //zeros the variable counter
}
}
}
};
Note:
am use code vision AVR
and protus7
i am sorry for bad language.
happy new year
sami