Created
November 19, 2015 03:01
-
-
Save houhr/1025447c68f624ddc197 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 <Adafruit_NeoPixel.h> | |
#define PIN 13 | |
#define NUMPIXELS 8 | |
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); | |
int sensorValue; | |
void setup() { | |
// put your setup code here, to run once: | |
pinMode(11, OUTPUT); | |
pinMode(12, OUTPUT); | |
pinMode(13, OUTPUT); | |
pinMode(A0, INPUT); | |
digitalWrite(11, LOW); | |
digitalWrite(12, HIGH); | |
digitalWrite(13, HIGH); | |
Serial.begin(9600); | |
pixels.begin(); | |
pixels.setBrightness(30); | |
} | |
void loop() { | |
// For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one. | |
sensorValue = analogRead(A0); | |
Serial.println(sensorValue); | |
if (sensorValue > 600) { | |
for(int i=0;i<NUMPIXELS;i++){ | |
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255 | |
pixels.setPixelColor(i, pixels.Color(0,150,0)); // Moderately bright green color. | |
} | |
pixels.show(); // This sends the updated pixel color to the hardware. | |
delay(500); // Delay for a period of time (in milliseconds). | |
} else { | |
for(int i=0;i<NUMPIXELS;i++){ | |
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255 | |
pixels.setPixelColor(i, pixels.Color(0,0,0)); // Moderately bright green color. | |
} | |
pixels.show(); // This sends the updated pixel color to the hardware. | |
delay(500); // Delay for a period of time (in milliseconds). | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment