# Switch Case Loop using FastLeds

**URL:** <https://forum.arduino.cc/t/switch-case-loop-using-fastleds/523146>\
**Category:** Programming\
**Created:** [April 28, 2018, 11:01pm UTC](https://forum.arduino.cc/t/switch-case-loop-using-fastleds/523146 "2018-04-28T23:01:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Knucklebut](https://avatars.discourse-cdn.com/v4/letter/k/e480ec/32.png) [@Knucklebut](https://forum.arduino.cc/u/Knucklebut)\
**Post date:** [April 28, 2018, 11:01pm UTC](https://forum.arduino.cc/t/switch-case-loop-using-fastleds/523146/1 "2018-04-28T23:01:00Z")

</div>

I built some custom headlights for a 4-Wheeler and I have always wanted to use Neopixels in one of my custom applications. So this was a great opportunity!

I wanted to add several different flash patterns but as my deadline approached, I realized I that my customer would have to toggle through allllll the patterns in order to turn them off. So as you can see in the code, I added an "off" function after each pattern so he can turn them off quickly if needed.  
I know there would be away to use the output of some IR remote or something similar, but in the particular application, where the customer goes off road all the time, I didn't want him to lose (or have to keep up with) the remote. That is why I used a momentary switch.

Finally, my question is, how would one of you have gone about this code where you HAVE to use a button (or multiple, but the fewer the better). Can one of you think of a way the user could hold the button for a set amount of seconds to turn the Neopixels off?  
On a side note, I wanted the pixels to "Meteor Rain" with ignition, however, I wanted them to stop after a certain amount of "raining" they would just go on and on.

Thanks in advance!

For anyone intrested I used a 12V to 5V Converter for the Arduino and the Neopixels

[FastLEDheadlights.ino](https://forum.arduino.cc/uploads/short-url/iJHzjLM5pyF8zUEg5RwGiyTWKDs.ino) (22.3 KB)

---

<div class="post-metadata">

**Author:** ![ieee488](https://avatars.discourse-cdn.com/v4/letter/i/d2c977/32.png) [@ieee488](https://forum.arduino.cc/u/ieee488)\
**Post date:** [April 28, 2018, 11:18pm UTC](https://forum.arduino.cc/t/switch-case-loop-using-fastleds/523146/2 "2018-04-28T23:18:32Z")

</div>

Pushbutton to switch between modes where one of the mode is OFF.

[http://forum.arduino.cc/index.php?topic=21042.0](http://forum.arduino.cc/index.php?topic=21042.0)

---

<div class="post-metadata">

**Author:** ![INTP](https://avatars.discourse-cdn.com/v4/letter/i/a183cd/32.png) [@INTP](https://forum.arduino.cc/u/INTP)\
**Post date:** [April 29, 2018, 1:02am UTC](https://forum.arduino.cc/t/switch-case-loop-using-fastleds/523146/3 "2018-04-29T01:02:42Z")

</div>

....how about an off switch on the power line....

---

<div class="post-metadata">

**Author:** ![Knucklebut](https://avatars.discourse-cdn.com/v4/letter/k/e480ec/32.png) [@Knucklebut](https://forum.arduino.cc/u/Knucklebut)\
**Post date:** [April 29, 2018, 2:44am UTC](https://forum.arduino.cc/t/switch-case-loop-using-fastleds/523146/4 "2018-04-29T02:44:02Z")

</div>

> INTP:  
> ....how about an off switch on the power line....

Well I thought about a SPDT toggle switch, but, I wanted the first pattern "Meteor Rain" to activate with Ignition I.E. when the user turned the key for the bike.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 5, 2021, 11:09pm UTC](https://forum.arduino.cc/t/switch-case-loop-using-fastleds/523146/5 "2021-05-05T23:09:43Z")

</div>

Closed on May 5, 2021, 11:09pm UTC


