Skip to content

Instantly share code, notes, and snippets.

@barnslig
Created January 1, 2016 23:15
Show Gist options
  • Save barnslig/8f0275d2555f44d36776 to your computer and use it in GitHub Desktop.
Save barnslig/8f0275d2555f44d36776 to your computer and use it in GitHub Desktop.
#include <Adafruit_NeoPixel.h>
#define POTI_PIN A0
#define WS2812_PIN 5
#define WS2812_LEDS 1
#define STEPS 3
int currentStep;
Adafruit_NeoPixel leds = Adafruit_NeoPixel(WS2812_LEDS, WS2812_PIN, NEO_GRB + NEO_KHZ400);
void setup() {
Serial.begin(115200);
Serial.setDebugOutput(true);
leds.begin();
}
void loop() {
int val = analogRead(POTI_PIN);
//Serial.println(val);
// Continous RGB LED logic
int rgbVal = val * 255/1024;
leds.setPixelColor(0, rgbVal, 255-rgbVal, 0);
leds.show();
// Debounced step logic
int newStep = val / (1024/STEPS);
if(newStep != currentStep) {
currentStep = newStep;
Serial.println(currentStep);
// Add HTTP API call logic here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment