Go Down

Topic: Detecting button state with out interrupting flow (Read 182 times) previous topic - next topic

IDGET

Like many noob here,

I have searched around for this answer but I am not entirely sure what it might be referred to and the keywords I use bring me to topics that do not pertain to it.

So I am creating an Arduino control project for a Jeep build I am doing. I am in the process of wiring everything now and want to display some different status' on a small LCD. I am going to have all my headlights and taillights hardwired to a toggle switch and straight to the battery. I do not want to control the lights via the Arduino in case it fails. I would like to know if the lights are on or off to display on the LCD. Is there a way to pull the state of the switch or the state of the lights without interfering with the lights?

side note: this is running off a 12v car battery


Paul_KD7HB

Any suggetions?
Sure! Add a cheap automotive relay in parallel with the lights and connect the common terminal of the relay to ground and the normally open terminal to the Arduino pin. Program the Arduino pin to use internal pullup resistor. When the lights are on the relay will be closed and the Arduino pin will be low and you program can test for the pin low condition.

Paul

Go Up