Once you have them all worked out, each one bevomes a simple "if" statement switching the required led on or off. Then go down each sequence and write the step number against each one, remembering each step is equivalent to a delay (25). Remember all the "off" steps to go with each "on" step. It will help to write each of your separate sequences out on paper or a spreadsheet. The UNO is programmed to output logical signals with different sequence over its pins with the appropriate timing pattern to show different LED light. At the end of the sequence (5000 or whatever) one more "if" will be needed to set sequenceStep back to zero. Then, using only "if" statements (no for or while loops allowed) check for the step numbers where each led must be switched on or off. Add one to this variable after the delay. Also make a new int variable called sequenceStep or something. Have a single delay of 25 at the start of your loop () function. Make all other delays into multiples of that, so 50, 75, 100, 250, 1000 etc whatever you need. This is what I suggest: your shortest delay is 25. To have several sequences running together, you not only have to get rid of delay () but also use another method of keeping track of where you are in each sequence. When using delay () to time your flashes, the other thing you are doing, perhaps without realising, is using the current command in the program to keep track of where you are in the led sequence. Hi max_lumens, here is my suggestion for you. then 4 quick blinks the other side (back and forth) R/C police car strobe blue and red lights, 4 quick blinks one side, from right to left with a double blink on the final led R/C police car rear yellow traffic arrow, moving I left out some of the other code required to make this work, but i did get it to work ok, the code itself is not the problem, its how to rewrite it that is making me nuts. The code below works perfectly but all it will do is show you what i want to achieve, i am perplexed on how to write this same code in a way that i can have the strobes flashing while the arrow moves across. I understand i cannot use DELAY and that i should be using MILLIS() but i am having trouble grasping how to code a "4 quick blink" type of strobe light with millis(). I cannot figure out the code to make this work. I am trying to make the usual blue and red lights strobe back and forth WHILE also having a traffic arrow of 8 LEDs move to the left. My problem is that I am trying to create a realistic flash pattern for an R/C police car and I can get the lights to flash perfect each on their own routine, but i cannot combine 2 routines run simultaneously. Please forgive any newbie mistakes i make as i am a first time poster and relatively new to the whole arduino coding world.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |