maxim10373
Advanced Member level 4
Friends
This is a simple LED on off with a push button program. can you help me to add ; when push the button more than twenty (20) seconds
The LED should be OFF.
regards
AJAY
This is a simple LED on off with a push button program. can you help me to add ; when push the button more than twenty (20) seconds
The LED should be OFF.
regards
AJAY
Code:
[#include<reg52.h> /* special function register declarations */
/* for the intended 8051 derivative */
sbit LED_pin = P2^0; //Defining LED PIN
sbit switch_pin = P0^0; //Defining Switch PIN
void Delay(int); //Function prototype declaration
void main (void)
{
switch_pin = 1; // Making Switch PIN input
LED_pin=1; //LED off initially
while(1) //infinite loop
{
if(switch_pin == 0 ) //If switch pressed
{
LED_pin = 0; //LED ON
Delay(2000); //Delay
LED_pin = 1; //LED OFF
}
}
}
void Delay(int k)
{
int j;
int i;
for(i=0;i<k;i++)
{
for(j=0;j<100;j++)
{
}
}
}]