Using a Mega, I have pushbutton input switches, which I've numbered 1-8 hooked up to Pins 22-29. I have eight outputs going to LEDs, which I've numbered 1-8 hooked up to Analog Pins 6-13.
I want the program logic to say this: "In order to proceed, the light to the LEFT of the switch just pressed must be ON."
So, in the diagram below, pressing switch 2 will do nothing because the LED to its left (LED 1) is off. Pressing switch 3 will do something because the LED to its left (LED 2) is on.
SWITCHES: 1 2 3 4 5 6 7 8
LEDs: off on off on on on on off
so, my pseudocode looks like...
// user pressed a switch causing 'pressed' to be the appropriate number - - say pressed = 3
if (LED[pressed-1] == HIGH) // Is the LED just to the left of this switch lit?
do something; //if OFF, do nothing
...so The Question: Can I directly ask if a specific LED output pin is HIGH or LOW??
If not, I could set up an array of 8 integers and and send the appropriate array element HIGH when I turn the LED on, and send that element LOW when I turn the LED off. - Right??