Skip to content

Instantly share code, notes, and snippets.

@nervetattoo
Created October 30, 2016 13:58
Show Gist options
  • Save nervetattoo/2acdb038afd6511d8fb387ed45de9b63 to your computer and use it in GitHub Desktop.
Save nervetattoo/2acdb038afd6511d8fb387ed45de9b63 to your computer and use it in GitHub Desktop.
#include "neopixel.h"
#define PIXEL_COUNT 29
#define PIXEL_PIN D2
#define PIXEL_TYPE WS2812B
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
int pos = -1;
int lightUp(String strPos) {
pos = strPos.toInt();
return pos;
}
void setup() {
Particle.function("lightUp", lightUp);
strip.begin();
strip.show();
}
void loop() {
for (int i=0; i<strip.numPixels(); i++) {
if (i == pos) {
strip.setPixelColor(i, strip.Color(255, 0, 0, 255));
} else {
strip.setPixelColor(i, strip.Color(0, 0, 0, 0));
}
}
strip.show();
delay(1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment