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.

Led onn off with single push botton

Status
Not open for further replies.

maxim10373

Advanced Member level 4
Full Member level 1
Joined
Feb 26, 2010
Messages
116
Helped
1
Reputation
2
Reaction score
2
Trophy points
1,298
Visit site
Activity points
2,066
Dear All
Plz check this attachment
I need a simple program for this circuit.
when S1 pressed ; LED1 & LED3 ON (HOLD IT)
when S1 pressed again ; LED1 & LED3 OFF and LED2 & LED 4 ON
Repeat this function

I need to use AT89C2051 mcu

Thanks
Ajitkumar
 

Attachments

  • LED.pdf
    8.9 KB · Views: 164

You didn't tell the compiler.

change the below code as suit to your compiler.
Code:
void main()
{
	unsigned int flag = 0;
	while(1)
	{
		if(Button_pressed)	// check for button is pressed
		{
			flag++;		// increment a variable

			if(flag > 2)	
			{
				flag = 1;	
			}
		}

		if(flag == 1)	
		{	
			LED1 = HIGH;
			LED3 = HIGH;

			LED2 = LOW;
			LED4 = LOW;
		}

		else if(flag == 2)
		{
			LED1 = LOW;
			LED3 = LOW;

			LED2 = HIGH;
			LED4 = HIGH;			
		}
	}
}

Best wishes :)
 
Sir
Can I use Keil mcs 51 ?

Thanks a lot

Ajitkumar

- - - Updated - - -

Dear sir,
please give me .hex file if possible
its very urgent .

Regards
Ajitkumar
 

Sir
Can I use Keil mcs 51 ?

Thanks a lot

Ajitkumar

- - - Updated - - -

Dear sir,
please give me .hex file if possible
its very urgent .

Regards
Ajitkumar

hemnath suggested simple c logic we don't have any pin and hardware details which pin is S1,where LED1,LED2,LED3,LED4 connected
so its not possible to build code for you.You can do it by just in some minutes rather waiting for others. you can use keil compilers.
 
According to your hardware connection you are connect switch in p3.2 and led1-p1.0, led2-p1.1, led3-p1.2, led4-p1.4. So, that's way here is your hex file and according to that connection this is the hex file, now you can check it.
 

Attachments

  • New Text Document.txt
    163 bytes · Views: 140

Hi sir
The circuit is working but, if press the button LED only BLINK not holding
I have attached the c file which is you given'
My requirement is;
At the Normal stage both LED s are OFF
when we push the input signal LED1& LED3 are ON (in continue ON when its get the next signal)
when we push again the input signal LED2& LED4 are ON LED 1&3 are goes OFF
This cycle repeat
Can you help once again
Regards
Ajitkumar
 

Attachments

  • led pro.txt
    949 bytes · Views: 123

Try the attached .hex file. You have to pull up P3.0 to +5V using a 10k resistor. Code Compiled for 11.0592 MHz. mikroC PRO 8051 Compiler is used. You can download demo version of mikroC PRO 8051 Compiler from mikroElektronika.

Button has to be pressed and released. Only then the press is registered.
 

Attachments

  • LED Control.rar
    21.6 KB · Views: 113
I have provided the complete source code (mikroC PRO 8051) and it also includes the .hex file.
 

sir
Its working ok
Only the problem when power on the circuit, All LED s are need to OFF
Only work with Input signal.
what to do plese tell me
Regards
Ajitkumar
 

As same working.Both LEDs are ON

If you are having same hardware connection as in the post #1 then you will need to reverse your led and change their common Pins(K) to connect gnd if you want to use post #14 hex file.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top