This first one is your basic classic blinking flasher. Just like pretty much every bike light out there. Basically just turn all the NeoPixels on, then turn them off, then back on again, etc.
/////////////////////////////////////////////////////////////////////////////// // Circuit Playground Bike Light - Flasher // // Author: Carter Nelson // MIT License (https://opensource.org/licenses/MIT) #include <Adafruit_CircuitPlayground.h> #define COLOR 0xFF0000 // change this to your favorite color #define FLASH_RATE 250 // lower is faster /////////////////////////////////////////////////////////////////////////////// void setup() { CircuitPlayground.begin(); // Make it bright! CircuitPlayground.setBrightness(255); } /////////////////////////////////////////////////////////////////////////////// void loop() { // Turn on all the pixels to COLOR for (int pixel=0; pixel<10; pixel++) { CircuitPlayground.setPixelColor(pixel, COLOR); } // Leave them on for a little bit delay(FLASH_RATE); // Turn off all the NeoPixels CircuitPlayground.clearPixels(); // Leave them off for a little bit delay(FLASH_RATE); }
Pretty simple, but it does get people's attention. Play around with these two lines of code:
#define COLOR 0xFF0000 // change this to your favorite color #define FLASH_RATE 250 // lower is faster
Try changing the COLOR
to 0xff07ee. What color is that? Want to make it blink faster? Try lowering FLASH_RATE
down to say something like 100 or 50.
Congratulations. You now have a bike light you can customize to your favorite color!
But why just have a boring old blink blink blink? We can do so much more...
Text editor powered by tinymce.