Click here to Skip to main content
15,891,888 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to control 4 led s using switch. I pressed switch one time first LED is turn on. after some time another led s are turn on/ off one by one. the delay is not mentioned.

how ever I want to get status of led. which is the turn on led now?

What I have tried:

without using sensor, how to do that?
Posted
Updated 20-Mar-17 2:23am
Comments
[no name] 20-Mar-17 8:13am    
https://www.codeproject.com/Questions/1177273/Control-LED-s-using-one-switch-and-get-status-of-w

1 solution

Just track the status within your program using a variable:
Whenever a LED is switched on or off by your program set the status variable accordingly.

The above requires the state to be known when starting the program (e.g. by switching all LEDs off).

As an alternative read the pin state of the LED ports using digitalRead(). This will work also for ports defined as output.
 
Share this answer
 
Comments
SandiT 21-Mar-17 14:16pm    
Thank You very much.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900