This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Pin reading Problem with at89c2051

i use at89c2051 micro controller there is a problem with reading the pin value after declaring pin 1(input pin)......controller gives wrong execution...

i already declare pin as a input pin i also place meaningfull part of code..

i also do simulation for same in proteus it work ok but it is not work in real hardware,also there is not any problem in hardware please suggest what to do....

the problem is that both part is executed in superloop (while(1)) here auto is switch

#define ON   0
#define OFF  1

sbit AUTO=P3^4;
sbit LED1=P1^0;
sbit LED2=P1^1;

void main()
{
  unsigned char event,mevent;
  AUTO=1;LED1=0;LED2=0;

 if(AUTO==ON)
  {event=0;}
else if(AUTO==OFF)
  {event=1;}

while(1)
{
  if(AUTO==ON)
  {LED1=ON;}
   else if(AUTO==OFF)
  {LED2=ON;}
}

}

0