0

I have a group project in school. My group mates want an alternate blinking, rapid blinking and fading LEDs in our project. The thing is they want it to go simultaneously. Is there anyway I can do that?

  • they want it to go* – Elijah Peralta Dec 12 '17 at 12:11
  • 2
    There is an edit link under the post you can use to correct typos or add new information. – ratchet freak Dec 12 '17 at 12:13
  • Don't use delays but use millis to calculate the time that has passed, and change the state of the led based on that. So for example the normal blinking you want 1000ms ON and 1000ms off. So you continually check to see if 1000ms has passed, and if so switch the led state. You can see some example code and further explanation at arduino.cc/en/tutorial/BlinkWithoutDelay . For the fading, you can use the same method and increase/decrease the brightness say every 50ms (and use an additional variable to remember if you fading IN or OUT). – Gerben Dec 12 '17 at 15:30
1

If you change each led in order they will change fast enough that you cannot tell. The lag between changes will be on the order of microseconds.

If you want to dive into direct port manipulation you can change multiple leds at the same time. Though not all at the same time instead they are grouped.

|improve this answer|||||
  • Out of curiosity how would direct port manipulation work? – Elijah Peralta Dec 12 '17 at 12:19
  • There are special globals where you can assign certain values to affect the pins. Check the specsheet for the details. – ratchet freak Dec 12 '17 at 12:23
  • 1
    @ElijahPeralta: Direct port manipulation. – Edgar Bonet Dec 12 '17 at 15:00
0

Not really. Because it can execute only instruction at a time. But due to the persistence of vision, you can always fool your eyes by processing leds so fast, in the order of microseconds. It will make us think that all LEDs are controlled at the same time.

|improve this answer|||||

Not the answer you're looking for? Browse other questions tagged or ask your own question.