Hi all!
My project is a vehicle light system, turn indicators, brake lights and such, and my solution revolves around pin extender IC chips, MCP 23008 and 23017 to be specific, controlled by a arduino nano.
The pin extenders are all tucked away inside a pre-existing housing, rear light, front light, trailer and handlebar and each extra light (turn indicators and so on) and button (functions) connects to the appropriate breakout card, rear turn indicator connects to the rear light pin extender card and so on.
This means i have up to 5 different output pins for each "function" as well as a few duplicate input pins.
Currently im using multiple digitalWrite´s, one for each output pin, but that creates a LOT of code lines.
I would like to define my functions with a list of function pins, something like:
leftTurn = frontLeftPin, rearLeftPin, trailerLeftPin, arduinoLeftPin
and use it like:
digitalWrite(leftTurn, leftState).
I would also like to define hazard lights in similar manner, like
hazLights = leftTurn, rightTurn, brakeLights
digitalWrite(hazLights, hazLightState)
Now the question is, how is this done?
Is it even possible?
I have gathered that arrays would kind of solve it, to have a repeat that steps thru each pin to toggle it, but it doesnt seem to allow me to set all array items at the same-ish time and i havent found a way to call multiple arrays, to call both right and left turn indicators for hazard lights.
In any way, i kind of dont like the array solution, it somehow feels wrong for this application..
I havent actually studied any programming, just trying to understand from examples and web tutorials so please treat me as newbie, even if this project is a bit over newbie-level.