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] how to coding led on off

Status
Not open for further replies.

joynal

Newbie level 6
Joined
Apr 2, 2012
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,370
How can i coding,


when 1st switch press 1st led off 2nd led on, again 1st switch press 1st led on 2nd led off.

when 2nd switch press 1st led off 3rd led on, again 2nd switch press 1st led on 3rd led off.


this like coding....
 

Jonal,

I'm sure many people wanted to help you...but couldn't understand your english.

I've read your post 4 times myself.

Before honing your C language skills - I really suggest that you improve your English! It'll be just as (or more) beneficial...
 

I think that means switch 1 alternates LED1 and LED2 and switch 2 alternates LED1 and LED3.

'Joynal' we need more information:

1. what happens if switch 1 and switch 2 are pressed at the same time?
2. what language are you coding in?
3. what processor is the code going to run on?

Brian.
 
According to his other threads he is using 8051.
 

thank you for replay betwixt


(switch 1)
if switch 1 press led1 off and led2 on, if i press switch again do alternative.

(switch 2)
if switch 2 press led1 on and led3 on, if i press switch again do alternative.

i using c and mikroc software, and i want to run PIC16F877A
 

Without knowing how the switches and LEDs are wired to the PIC it's difficult to give exact code but you should be able to write something using this as a guideine:

1. read a port to see if one of the switches has been pressed
2. see if it is switch 1, if it is and LED1 is lit, turn LED1 off and turn LED2 on. If LED1 is not lit, turn it on and LED2 off.
3. wait for switch 1 to be released.
4. if it was switch 2, if it is and LED1 is lit, turn it off and turn LED3 on. If LED1 was not lit, turn it on and turn LED3 off.
5. wait for switch 2 to be released.

If you draw a flow chart you will see it is really easy. If you construct it, remember to add resistors in series with the LEDs to limit their current and use pull-up or pull-down resistors on the switch input pins.

Brian.
 

thank you

my code is Solved...
 

It would be good forum practice to report the solution briefly...
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top