Suppose I have three led's set up and a mechanical switch for each. The led anodes go to arguino pins via resistors, the led cathodes go to each mechanical switch and then to ground. The arguino sends a HIGH command to each led but only the one with the switch engaged lights up. That is the setup.
Now, is there a way to recognize that an led is lit and to be able to set a condition based on that confirmation. I would like to use a selector switch but not have it directly plugged into the arguino.
Hi, you might want to try setting your output pins to INPUT_PULLUP and using digitalRead() to read the pin. If the switch is not pressed, the reading will be HIGH. If the switch is pressed, the reading might be LOW. Worth a try, because if it does work, it won't use any more Arduino pins.
With INPUT_PULLUP, the led will be very dim, so use the setting only while reading the pin, then immediately set it back to OUTPUT.