Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Simple led on off circuit 8051

Status
Not open for further replies.

maxim10373

Advanced Member level 4
Joined
Feb 26, 2010
Messages
115
Helped
1
Reputation
2
Reaction score
2
Trophy points
1,298
Activity points
2,063
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

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++)
        {
        }
    }
}]
 

The same problem has been reported in other threads; you are not implementing any counter based on interrupt timer. Take a look at the examples available for the compiler you're using.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top