Skip to content

Instantly share code, notes, and snippets.

@Tiriree
Created February 8, 2017 07:57
Show Gist options
  • Save Tiriree/cc677fbaf3f88ed97d2f24f7d50acee2 to your computer and use it in GitHub Desktop.
Save Tiriree/cc677fbaf3f88ed97d2f24f7d50acee2 to your computer and use it in GitHub Desktop.
//Tangible Interaction - W2 - Lighting Controller
//Tom Igoe
#include <Adafruit_NeoPixel.h>
#define PIN 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, PIN, NEO_GRB + NEO_KHZ800);
int sensorValue = A0;
int sensorValue2 = A1;
int sensorValue3 = A2;
int currentColourValue;
int currentColourValue2;
int currentColourValue3;
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
currentColourValue = (255 - map( analogRead(sensorValue), 0, 1023, 0, 255 ) );
currentColourValue2 = (255 - map( analogRead(sensorValue2), 0, 1023, 0, 255 ) );
currentColourValue3 = (255 - map( analogRead(sensorValue3), 0, 1023, 0, 255 ) );
colorWipe(strip.Color(currentColourValue, currentColourValue2, currentColourValue3), 50); // Red
}
void colorWipe(uint32_t c, uint8_t wait) {
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(10);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment