I've been sitting for hours now trying to figure out how to do this within coding and tried to look at other examples of code to learn or figure out but the explanations I have found haven't quite gotten me to an understand of how to achieve this. What I want to do (just getting back into Arduino with some silly projects as challenges) is to turn on one LED in a set of 10 whilst switching off the previous one. The logic:
Program starts All LED OFF digitalRead button "momentary button" When button reads HIGH AND led1 = 0 led1 ON "it must stay on" When button reads HIGH and led1 = 1 "its ON" led1 OFF and led2 ON When button reads HIGH and led1=0, do nothing, When button reads HIGH and led2=1 led2 OFF and led3 ON
What I am thinking is using a led condition statement to compare the digitalRead with the LED array - the led condition statement will hold the index number of which LED is ON. The if statement will then find that index number of the ON LED, turning off that led and turning on the next led in that array. Then put the index number of the LED that was just turn ON in the led condition statement.
I know I can do this with a shift register, but I'd like to learn how to do this without a shiftregister using basically 10 pins as output, changing between the pins within the sketch.
I have looked at the example of setting up a LED array which will then make a chase light - but I cannot figure out how to adapt the code to not check on time but check a digitalRead. Make sense?
Any help will be greatly appreciated - even a sketch that already does it. Next I'll learn how to do it with a shift register.