Led not blinking using 8051!

You can post your problem related to Proteus Projects here. We will try our best to help you out.
Post Reply
Josephine
Posts:10
Joined:Sat Feb 25, 2017 8:24 am
Led not blinking using 8051!

Post by Josephine » Sat Feb 25, 2017 11:25 am

Hey guys!

I setup a breadboard circuit to do the basic single led blinking test using a AT89C52 chip. However, I do not get any blinking, it just lights up until power is stopped. I had only enabled a single bit for port0.0. The code is below. However, the led lights up even if I connect it to any other port. Is it a problem with my code? Please check it. Thank You.

Code: Select all

#include<reg52.h>
sbit led = P0^0;
 
void delay(int time)        //This function produces a delay in msec.
{
    int i,j;
    for(i=0;i<time;i++)
     for(j=0;j<1275;j++);
}
 
void main()
{
     while(1)
     {
          led=0;
          delay(500);
          led=1;
          delay(500);
     }
}
 

Junaid_Shahid
Posts:110
Joined:Tue Feb 14, 2017 9:00 am

Re: Led not blinking using 8051!

Post by Junaid_Shahid » Sat Feb 25, 2017 11:26 am

Josephine wrote:
Sat Feb 25, 2017 11:25 am
Hey guys!

I setup a breadboard circuit to do the basic single led blinking test using a AT89C52 chip. However, I do not get any blinking, it just lights up until power is stopped. I had only enabled a single bit for port0.0. The code is below. However, the led lights up even if I connect it to any other port. Is it a problem with my code? Please check it. Thank You.

Code: Select all

#include<reg52.h>
sbit led = P0^0;
 
void delay(int time)        //This function produces a delay in msec.
{
    int i,j;
    for(i=0;i<time;i++)
     for(j=0;j<1275;j++);
}
 
void main()
{
     while(1)
     {
          led=0;
          delay(500);
          led=1;
          delay(500);
     }
}
 
50ms is too short. Try 500ms.
please check: LED Blinking Project Using 8051 Microcontroller

Post Reply