Hello, I have a project and a part of it is 2 functions under 2 buttons, one of the function wchich im currently working on is when you press button leds start blinking from 1st to 7th with 1 second delay, so at the start 1st one lights up for a second, then its turn off and second one lights up and so on. Heres code that I made:
The problem is that program works until millis will not be greater than 7000, and i dont know how to make it work like i want to. At first i tried to make it with for loop, but I wasnt able to delay it without using delay funtion of course, beacuse it cant be here (I know its under first if but its not that bad, but i will try to make it with millis later). Can anyone help??
I still wrong, you are miss counting the braces }
For the whole loop function there must be an equal number of { and }
However it still contains the totally incorrect use of millis, it keeps on going but to use it as an index to an array, it will go wrong once you run out of valid index values.
I dont know what youre talking about the braces, beacuse it compiles and number of { are equal to } in void loop, but thats why im asking for help, I dont know how to write a good code to make led lights switch with 1 second delay
No.
At least not in the code you posted, you missed one when you highlighted the code for copying in the IDE. To avoid this then use the "select all" option in the IDE before the copy for forum operation.
I dont think i was using i, but i was using long, and i was trying to do something with current millis, previous millis and interval but the code here is the closest one i was able to get
If you don't believe me then copy what you posted by using the copy icon in the top right hand corner, and then paste it into a new sketch in the IDE and then try to compile it.
If you can't handle copy and paste what hope do you have of learning to code?
Forget using millis and use instead a for loop to turn your LEDs on and off. Use a delay call to get the timing right.
welcome to the forum.
As soon as you start asking specific questions you will get helpful answers.
Specific answers are much much easier to answer.
Here is a tutorial how to code non-blocking timing based on millis().
I am pretty sure that you will understand the everyday description of the tutorial