Regarding some tutorial on the web, i use an Arduino nano with :
LED strip on D7, +5V and Ground
Push button on :
--- 5V (red wires with green heat skrink tube)
--- Ground with 20k resistor (didn't work without it...) (black wires with green heat shrink tube)
--- Digital pin 2 to 6 with a 10k resistor inside the red heat shrink tube.
And as you guess, when i press one button, all the button fire....
I doubt there's much we can do without a schematic unless it's software. I can't help you with the software, but if it's hardware and you're serious about fixing it print out the schematic, get a meter and put it in resistance/continuity mode, ohm out each and every connection , and if it passes, highlight yellow
on the schematic with a felt tip highlighter.
Do that for the entire circuit.
Software is not my area of expertise but even I can see you don't have any diagnostic prints so it's no wonder you have no idea what's happening. Add print statements everywhere so you can read the states. I would also add delays to see if there is a timing issue. I would suggest adding a statement to blink the onboard led for a second if 'state' = expected state but the print statements should tell you that.That's about the most I can say on software but I've debugged similar sketches by adding delays and print statements and using the
serial monitor or a terminal cspture program like Clear Terminal.
The switches are not wired right. Disconnect the 5V wires from all the switches. Connect one side of the switches to ground. Remove all of the resistors. Wire the other side of each switch to an input pin. In setup(), set the plnMode for the switch pins to INPUT_PULLUP. The inputs will read LOW when the switch is pressed so change your code accordingly.
They are perfectly ordinary pushbuttons with two terminals.
It is identical to this concurrent thread. Just a misunderstanding of how to make connections.
You could leave the black wires with the resistors in place, cut off the black wires connected together and connect the red wire to ground instead of 5 V. Then do what groundFungus explains in the code.
Sorry for the delay, I was unable to login to the forum, need to try all the browsers I have :o
groundFungus:
The switches are not wired right. Disconnect the 5V wires from all the switches. Connect one side of the switches to ground. Remove all of the resistors. Wire the other side of each switch to an input pin. In setup(), set the plnMode for the switch pins to INPUT_PULLUP. The inputs will read LOW when the switch is pressed so change your code accordingly.
Quickly : totally did it ! Thanks, everything is now working !
raschemmel:
Software is not my area of expertise but even I can see you don't have any diagnostic prints so it's no wonder you have no idea what's happening. Add print statements everywhere so you can read the states. I would also add delays to see if there is a timing issue.
I voluntary remove the Serial.print to put a smaller code, but I use it a lot
Paul__B:
You could leave the black wires with the resistors in place, cut off the black wires connected together and connect the red wire to ground instead of 5 V. Then do what groundFungus explains in the code.
I ended by doing what groundFungus said, so something like that :
(not exactly, I have a 5V input from the plug)
I guess it is simpler, not using any resistor
Thanks to both of you.
raschemmel:
If all the switches are wired across 5V wouldn't it reset the board every time you press one ?
..... Indeed
Thanks you all for the quick replies, all is working, can give it to my nephew tomorrow