Hi! Thanks for looking. I am working on a project for a miniature. I have very little experience in this area. I have looked at some other threads and it mostly seems way over my head.
I want 3 LEDs to come on and stay on when I press one button, and 3 to come on and stay on when I press another button. The rub is I want the number (between 1 and 3) of LEDs that light up to be random every time I press the button.
I bought an uno, LEDs and some resistors and such. What other hardware do I need? Any help with the programming or directions to helpful resources would also be very helpful. Thanks a ton!
Your description is not quite clear. On the one hand "I want 3 LEDs to come on and stay on when I press one button" and on the other hand "The rub is I want the number (between 1 and 3) of LEDs that light up to be random".
Please elaborate / rephrase.
From a programming perspective, the Arduino will' remember' the LEDs that are on. So on button press, switch LEDs on and remember which button was pressed so a second button press on the same button will not result in different LEDs being switched on.
Use INPUT_PULLUP for the pinMode of the button pins; this will prevent floating inputs and hence false readings of the button state; wire the buttons between pin and ground. When a button is pressed, the signal will be LOW, else HIGH.
Random number can be achieved using the random function.
When I press a button, I want 1,2 or 3 LEDs to light up (randomly) out of 3 possible LEDs. When I press the button again, I want the either 1,2 or 3 of the same potential LEDs to light again.
Is this something feasible by someone as inexperienced as myself?
Pick a random number between 1 and 3; this will give you the number of LEDs to light.
For this number (e.g. 2), pick new random numbers between 1 and 3; those are the LEDs that you want to switch on.
Switch the LEDs on (e.g. 1 and 3).