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

led lighting at a pin

I wrote the code for it in keil.The simulation worked perfectly but the hardware implementation for the same is not working properly.Please help

<
#include<reg51.H>
sbit IN = 0x91;
sbit OUT = 0xA1;
void main()
{ P1=0xFF;
P2=0x00;
while(P1_1==1)
{ P2_1=1;
} while(P1_1!=1)
{ P2_1=0;
} }

Parents
  • You haven't even included any delay in the program.
    The crystal oscillator, which i assume is of 11.0592MHz or 12MHz. At such a high frequency, the time period is 1 micro seconds. DO you think for such low time period, you will see the LED TURN ON? I think you won't. So you have to Turn ON the LED and give a big Delay which is atleast more than 250milli seconds.

    The main loop also terminates. why??
    In assembly, dont we write this at the end of the code?

    SJMP  $
    
    or
    
    LOOP:  SJMP  LOOP
    
    


    Use a infinite loop at the end of main so that main does not terminate.

    Read this book "8051 microcontroller and embedded system by Muhammad Ali Mazidi"
    The program for LED BLINKING is already written for you.
    Or else GOOGLE.

Reply
  • You haven't even included any delay in the program.
    The crystal oscillator, which i assume is of 11.0592MHz or 12MHz. At such a high frequency, the time period is 1 micro seconds. DO you think for such low time period, you will see the LED TURN ON? I think you won't. So you have to Turn ON the LED and give a big Delay which is atleast more than 250milli seconds.

    The main loop also terminates. why??
    In assembly, dont we write this at the end of the code?

    SJMP  $
    
    or
    
    LOOP:  SJMP  LOOP
    
    


    Use a infinite loop at the end of main so that main does not terminate.

    Read this book "8051 microcontroller and embedded system by Muhammad Ali Mazidi"
    The program for LED BLINKING is already written for you.
    Or else GOOGLE.

Children