I have been having some issues in learning how to code since i discovered that the delay function is more of a curse than a blessing. Now, i saw some tutorials about millis and i don't know how to implement them in my code, the blink rate for my Led's is not the same, i need something like 700 on 2300 off, and i don't know how to do that. I tried setting up different intervals (interval1=700 ; interval2=2300) and i'm still blocked in it. Can someone offer a sample of this type of code, i need something like this :
Green1=2300 -> Blue1=700 ->Green2=2300 ->Blue2=700 ->Green3=2300 -> Blue3=700.
You can just send me a pice of code that includes 2 Led's and i will try to figure out myself how to expand it, i just don't know how to set the time high and time low on each one of them.
I have also tried using this type of arrangement in my code just to see if it works, and it does keep the display on while running the LED loop, but is it a good idea or not?
First of all, that seems way easier than everything i've tried. Second of all, by my logic now all i have to do is add 5 more LEDs to that code (like const byte ledPin 1/2/3/4/5/ etc and pinMode for each) and than write " if " the command for each one. Seems legit, i will try it out.
Thank you so much for this, i was close to 8 hours on this matter and for the last 5 of them i knew it was not supposed to be that hard. I will look up the term "boolean" since i don't know what it is, and keep learning until i'm good enough to help others.
I am a good student usually, i don't lose patience, so i will probably spend this night learning structures and analyzing your reply to see what knowledge i can steal, because as much as i want this code to work perfectly, i also want it to be my own.
And.. not to be rude, but your code compiles,uploads, and when it gets to the arduino it won't work. Don't know why yet
Yes, i fixed it like 1 min after i sent you that reply, i tried to tell you earlier, but the website said i exceeded my post limit in a period of 5 minutes or so. Anyway, thank you a lot for your advice. I am on YouTube now, trying to get something out of those iterations you've mentioned. I have looked this up ( https://www.arduino.cc/en/Tutorial/ForLoopIteration ) but it doesn't seem to be what you meant, since it's using delays. My deadline for this project is 4 days, so i guess i've got it. You're pretty lucky for knowing all that, i have had so much good ideas for games and programs, even an OS in the past, but they went by while i was telling myself that i can't code. Now that i have to, i realize it's not that hard. At least at first.
The demo Several Things at a Time illustrates the use of millis() to manage timing. It may help with understanding the technique.
Using millis() is much the same as using your kitchen wall clock to time the cooking of a chicken. Using delay() is the equivalent of sitting watching the oven for 90 minutes - which you would not dream of doing. Instead you note the time when the chicken goes in the oven and periodically check the clock to see if the 90 minutes has elapsed.