robotics_mait
Junior Member level 3
BELOW IS GIVEN THE CODE IN C written in KEIL... and i am trying to execute the program in proteus isis 7 professional...
#include<reg51.h>
#define SENSOR P1
void norm_forw();
void right();
void left();
void stop_wait();
void delay_1s();
void delay_norm();
void wd_forw();
void main()
{
for(;
{
switch(SENSOR)
{
case 0xF8:
{
norm_forw();
break;
}
case 0xF9:
{
wd_forw();
break;
}
case 0xFB:
{
right();
break;
}
case 0xFA:
{
right();
break;
}
case 0xFD:
{
left();
break;
}
case 0xFC:
{
left();
break;
}
case 0xFF:
{
stop_wait();
break;
}
default:
{
left();
break;
}
}
}
}
void norm_forw(void)
{
P2=0x0A;
delay_norm();
}
void wd_forw(void)
{
P2=0x0A;
delay_1s();
}
void right(void)
{
P2=0x0B;
delay_norm();
}
void left(void)
{
P2=0x0E;
delay_norm();
}
void stop_wait()
{
P2=0x00;
delay_norm();
}
void delay_norm()
{
}
void delay_1s()
{
}
problem is that the program is all the time for all possible inputs executing same routine in the default statement,i.e,left() .............(this is all going on in proteus not real hardware)
what should be done to solve this?
#include<reg51.h>
#define SENSOR P1
void norm_forw();
void right();
void left();
void stop_wait();
void delay_1s();
void delay_norm();
void wd_forw();
void main()
{
for(;
{
switch(SENSOR)
{
case 0xF8:
{
norm_forw();
break;
}
case 0xF9:
{
wd_forw();
break;
}
case 0xFB:
{
right();
break;
}
case 0xFA:
{
right();
break;
}
case 0xFD:
{
left();
break;
}
case 0xFC:
{
left();
break;
}
case 0xFF:
{
stop_wait();
break;
}
default:
{
left();
break;
}
}
}
}
void norm_forw(void)
{
P2=0x0A;
delay_norm();
}
void wd_forw(void)
{
P2=0x0A;
delay_1s();
}
void right(void)
{
P2=0x0B;
delay_norm();
}
void left(void)
{
P2=0x0E;
delay_norm();
}
void stop_wait()
{
P2=0x00;
delay_norm();
}
void delay_norm()
{
}
void delay_1s()
{
}
problem is that the program is all the time for all possible inputs executing same routine in the default statement,i.e,left() .............(this is all going on in proteus not real hardware)
what should be done to solve this?