Skip to content

Instantly share code, notes, and snippets.

@kliph
Last active August 29, 2015 14:06
Show Gist options
  • Save kliph/8cebe921ead71e7b82bd to your computer and use it in GitHub Desktop.
Save kliph/8cebe921ead71e7b82bd to your computer and use it in GitHub Desktop.
#include <Adafruit_NeoPixel.h>
// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip1 = Adafruit_NeoPixel(2, 5, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip2 = Adafruit_NeoPixel(1, 6, NEO_GRB + NEO_KHZ800);
void setup() {
strip1.begin();
strip1.show(); // Initialize all pixels to 'off'
strip2.begin();
strip2.show(); // Initialize all pixels to 'off'
}
void loop() {
// set all NeoPixels in strip 1 to the same color:
for (int thisPixel = 0; thisPixel < strip1.numPixels(); thisPixel++) {
// set the color for all Pixels:
strip1.setPixelColor(thisPixel, 255, 255, 40);
int potValue1 = analogRead(0)/4;
// set the brightness for all Pixels, 0-255:
strip1.setBrightness(potValue1);
}
// set all NeoPixels in strip 2 to the same color:
for (int thisPixel = 0; thisPixel < strip2.numPixels(); thisPixel++) {
// set the color for all Pixels:
strip2.setPixelColor(thisPixel, 255, 255, 40);
int potValue2 = analogRead(1)/4;
// set the brightness for all Pixels, 0-255:
strip2.setBrightness(potValue2);
}
// send to all Pixles:
strip1.show();
strip2.show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment