Hi people, I would like to know if any of you could help me with this.
I am trying to get a sketch that can allow me to do the following:
My program has a variable (code)
5 digital inputs (buttons)
5 digital outputs (LEDs)
If "code" is true I want the buttons and the LEDs to activate so the user can input a value associated with that particular choice.
Example:
"code" is true
all lights turn on
user presses button1 (HIGH)
only led1 stays on and the rest go off (led2, led3, led4, led5)
What's the programme structure for this? I've been doing loads and loads of IF statements but I am sure there must be another way. Also how do you declare the pins and variables for this? Arrays? One by one?
Sorry that I am clueless right now but this whole thing is really new to me. I will appreciate your help. Thank you very much
If "code" is true I want the buttons and the LEDs to activate so the user can input a value associated with that particular choice.
How does code get a new value?
Arrays?
Most definitely, along with loops and functions.
Put the pin numbers of the inputs in one array. Put the pin numbers of the outputs in another array.
In loop, create a for loop to read the inputs, if necessary. If any input is high, call a function to set all pins LOW, and set the one pin HIGH (or all pins HIGH, and that one pin LOW).
Hi Paul, first thank you very much for clarifying this to me. I basically have the following:
An RFID reader. When the card is read it validates it against a mysql database through a php script and gets a response back to the arduino. If the RFID tag is on the database then it activates the buttons and the leds that I am trying to make work so that a user presses one button and then the value of that button is inserted into the database. I have managed to make everything work except that. I am not a programmer so I have basically copy-pasted-tweaked everything so far. It is like knowing how to read but not to write so that's why I asked for help.