Hi
I want to ON/OFF LED for 500 ms. I have written a program that suppose to ON/OFF LED for 500 ms
Environment : AT89C51, Keil,
When I compile code, LED turn on/off once for very short time and then goes off for forever. I don't have any idea why code it not working as it suppose to do ?
Edit, at the movement I do not want to use nested loop in delay function
I want to ON/OFF LED for 500 ms. I have written a program that suppose to ON/OFF LED for 500 ms
Environment : AT89C51, Keil,
C:
#include<reg51.h>
sbit LED = P2^0; /*LED connected at output Pin P2.0 */
#define LED_ON 1 // LED Turn ON
#define LED_OFF 0 // LED Trn OFF
/* Function to generate Delay*/
void Delay(DelayTime)
{
unsigned int count;
for ( count = 0; count < DelayTime; count)
{
}
}
int main ()
{
LED = LED_ON; //LED Turn On
Delay(5000000); //Wait 500 millisecond
LED = LED_OFF; //LED Trn OFF
Delay(5000000); // Wiat 500 millisecond
return 0;
}
Edit, at the movement I do not want to use nested loop in delay function
Last edited: