Created
January 27, 2017 08:11
-
-
Save MichMich/f74bfe2fed4c2228853ede50e723ff9f to your computer and use it in GitHub Desktop.
Arcade Neopixel Button
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Arduino.h> | |
#include <FastLED.h> | |
#define LED_PIN 7 | |
#define BUTTON_PIN 8 | |
CRGB leds[1]; | |
void setup() { | |
FastLED.addLeds<NEOPIXEL, LED_PIN>(leds, 1); | |
pinMode(BUTTON_PIN, INPUT_PULLUP); | |
} | |
void loop() { | |
static uint8_t hue = 0; | |
static uint8_t targetHue = 0; | |
FastLED.showColor(CHSV(targetHue, 255, 255)); | |
if (targetHue != hue) targetHue++; | |
delay(2); | |
if (!digitalRead(BUTTON_PIN)) { | |
hue += 8; | |
delay(20); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment