/* Week 7 assignement Holloboard by Joris */ #include // Define #define NUM_LEDS 3 #define DATA_PIN 6 #define BTN_PIN 10 #define BTN_DELAY 250 // Init Vars uint8_t j = 0; unsigned long mark; // neopixel Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, DATA_PIN, NEO_GRB + NEO_KHZ800); void setup() { pinMode(BTN_PIN, INPUT); strip.begin(); strip.show(); // Initialize all pixels to 'off' strip.setPixelColor(0, 255, 0, 0); } void loop() { // if button pressed chkBtn(digitalRead(BTN_PIN)); strip.setPixelColor(0, 255, 0, 0); strip.setPixelColor(1, 0, 255, 0); strip.setPixelColor(2, 0, 0, 255); delay(1000); } boolean chkBtn(int buttonState) { if (buttonState == HIGH && (millis() - mark) > BTN_DELAY) { j = 0; mark = millis(); return true; } else { return false; } }