I’m working on a blinking/fading lights program for Arduino. I’m trying to build in some interactivity that’s based on LED state and certain switch combinations. Consider: When a button is pressed, if an LED is ON I want to turn it off and if an LED is OFF I want to turn it on.
However, I’ve not been able to find any information about determining LED state. The closest was this question about Android, but I’m trying to find out if I can do this from the Arduino platform. Does anyone have any practical experience or advice?
You have several options:
One, you can store the LED state in a boolean, and on button press, negate that and write it to the LED port:
Two, if you don’t mind accessing the ports of the AVR directly: