Hey! Very new programmer here, would really appreciate any help.
I'm trying to make an array that turns on the LED pin values that I put inside of it.
Imagine there are buttons for the LED's, and you need to click them in the order of the LED's lighting up. How would you code that? and a step further, how would you confirm that the buttons clicked are in the same order as the LED's lighting up?
It sounds like you have not finished learning how to program yet.
Without looking, I bet one of the many button libraries will have a sample of an array of buttons. It is a trivial matter to extend that array to also include the LED pins.
Start by reading the pinned post re 'how to get the most from this forum'. When you have code that is mostly working, post it in code tags, any error log also in code tags, a picture of a hand drawn wiring diagram plus a brief statement of what you expect to happen and what is actually happening. That is a start.
Say more. Do the LEDs turn on in some random order that the player must match by pressing a corresponding button?
Do the LEDs stay on until the end of the round, or go off after some short time, then repeat after waiting a bit for the player?
What are the consequences of pressing the wrong next button? What happens if we make it through all N LEDs?
Arrays can hold pin numbers, pin numbers can be outputs or inputs. A simple solution to that part of your effort would be to have two arrays, one for the LEDs and one for the buttons, with the LED and button at the same index in each array woukd be the correspondence.
If you need an array of values scrambled for presentation in a random order, you can use a shuffle algorithm, add Arduino to any search to focus your results, viz:
no they won't turn on in a random order, I want to make an order that stays the same whenever the code runs again
The LED's wont repeat if you don't press anything and if you don't press anything in maybe like 30 seconds then I want the whole thing to restart
If you press the pattern the same as how it lit up then you move on to like a "next stage", I want it to be a memory game type thing with multiple stages
also ok, thank u for your guidance!! ill look into random orders too
This sounds like a game called Simon, there are quite a few Arduino versions to be found.
Here's one:
You might like the wokwi simulator for your own development efforts.
Simon can repeat LEDs and obvsly has to when the sequence is longer than N number of real LED/button combos.
The sketch in the link just adds a new random number to a stored sequence when the sequence length grows, that is to say after the player gets the current sequence correct and before the toy plays the sequence with an additional element.
The real Simon did not, I think, have a reward tone every time you got a sequence right. I don't like it, it messes up my memory of the so-far sequence.
A few other things I don't like, if I was taking more time I'd challenge myself to understand the code well enough to fix it to work how I wanted.
google for others. None of the code I saw was very complicated, at keast in terms of the language features used. A few were junk code or poorly presented; read around and dive in when something catches you fancy.
If it isn't quite Simon you are aiming at, please describe in some detail exact how you want this to work.