Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Adafruit_NeoPixel.h>
- #ifdef __AVR__
- #include <avr/power.h>
- #endif
- #define PIN 6
- #define BUTTON_PIN 9
- Adafruit_NeoPixel strip = Adafruit_NeoPixel(120, PIN, NEO_GRB + NEO_KHZ800);
- // IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
- // pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
- // and minimize distance between Arduino and first pixel. Avoid connecting
- // on a live circuit...if you must, connect GND first.
- bool oldState = HIGH;
- int showType = 0;
- void(* resetFunc) (void) = 0; //declare reset function @ address 0
- void setup() {
- pinMode(BUTTON_PIN, INPUT_PULLUP);
- strip.begin();
- strip.show(); // Initialize all pixels to 'off'
- }
- void loop() {
- // Get current button state.
- bool newState = digitalRead(BUTTON_PIN);
- // Check if state changed from high to low (button press).
- if (newState == LOW && oldState == HIGH) {
- // Short delay to debounce button.
- delay(20);
- // Check if button is still low after debounce.
- newState = digitalRead(BUTTON_PIN);
- if (newState == LOW) {
- showType++;
- if (showType > 9)
- showType=0;
- startShow(showType);
- }
- }
- // Set the last button state to the old state.
- oldState = newState;
- }
- void startShow(int i) {
- colorWipe(strip.Color(75, 0, 0), 50); // Red
- colorWipe(strip.Color(0, 75, 0), 50); // Green
- colorWipe(strip.Color(0, 0, 75), 50); // Blue
- theaterChase(strip.Color(75, 75, 75), 50); // White
- theaterChase(strip.Color(75, 0, 0), 50); // Red
- theaterChase(strip.Color(0, 0, 75), 50); // Blue
- rainbow(20);
- rainbowCycle(20);
- theaterChaseRainbow(50);
- resetFunc(); //call reset
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement