Created
October 29, 2019 17:39
-
-
Save sarahenglish/e1f80ffb713dc07f3d6ebad005a8c3ea to your computer and use it in GitHub Desktop.
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 <ADCTouch.h> | |
#include <Adafruit_NeoPixel.h> | |
int ref0; | |
int ref1; | |
int ref2; | |
int lightVal; | |
int limit=50; | |
#ifdef __AVR__ | |
#include <avr/power.h> | |
#endif | |
#define PIN 2 | |
Adafruit_NeoPixel strip = Adafruit_NeoPixel(30,PIN, NEO_GRB + NEO_KHZ800); | |
void setup() { | |
Serial.begin(9600); | |
ref0=ADCTouch.read(A0, 500); | |
ref1=ADCTouch.read(A1, 500); | |
ref2=ADCTouch.read(A2, 500); | |
} | |
void loop() { | |
int value0 =ADCTouch.read(A0); | |
int value1 =ADCTouch.read(A1); | |
int value2 =ADCTouch.read(A2); | |
strip.begin(); | |
strip.show(); | |
value0 -= ref0; | |
value1 -= ref1; | |
value2 -= ref2; | |
//lightVal=map(value0, -350, 500, 0, 255); | |
//Serial.print(lightVal); | |
//Serial.print("value0: "); | |
Serial.print(value0); | |
Serial.print("\t"); | |
//Serial.print("value1: "); | |
Serial.print(value1); | |
Serial.print("\t"); | |
//Serial.print("value2: "); | |
Serial.print(value2); | |
Serial.print("\t"); | |
Serial.print("\n"); | |
if(value0<limit && value1<limit && value2<limit) | |
{ | |
// Serial.print("white"); | |
// Serial.print("\n"); | |
for(uint16_t i=0; i<strip.numPixels(); i++) | |
{ | |
strip.setPixelColor(i,5, 5, 5); | |
strip.show(); | |
} | |
} | |
if(value0>=limit && value1<limit && value2<limit) | |
{ | |
for(uint16_t i=0; i<strip.numPixels(); i++) | |
{ | |
strip.setPixelColor(i,0, 0, value0); | |
strip.show(); | |
} | |
} | |
if(value0>=limit && value1>=limit && value2>=limit) | |
{ | |
for(uint16_t i=0; i<strip.numPixels(); i++) | |
{ | |
strip.setPixelColor(i,value2, 0, 0); | |
strip.show(); | |
} | |
delay(10); | |
for(uint16_t i=0; i<strip.numPixels(); i++) | |
{ | |
strip.setPixelColor(i,0, 0, 0); | |
strip.show(); | |
} | |
delay(10); | |
} | |
if(value0>=limit && value1>=limit && value2<limit ) | |
{ | |
strip.show(); | |
for(uint16_t i=0; i<strip.numPixels(); i++) | |
{ | |
strip.setPixelColor(i,value0, value1, 0); | |
strip.show(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment