Created
November 30, 2018 16:52
-
-
Save giantmolecules/32a877195e4f40934086026f4f84e9a0 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 6 | |
Adafruit_NeoPixel strip = Adafruit_NeoPixel(240, PIN, NEO_GRB + NEO_KHZ800); | |
int threshold = 160; | |
int sampleVal = 0; | |
int numPixels = 240; | |
void setup() { | |
Serial.begin(9600); | |
pinMode(13, OUTPUT); | |
strip.begin(); | |
strip.show(); // Initialize all pixels to 'off' | |
} | |
void loop() | |
{ | |
sampleVal = analogRead(0); | |
if (sampleVal > threshold) { | |
for (int j = 0; j < numPixels; j++) { | |
strip.setPixelColor(j, 255,255,255); | |
} | |
strip.show(); | |
} | |
for (int j = 0; j < numPixels; j++) { | |
strip.setPixelColor(j, 0,0,0); | |
} | |
strip.show(); | |
digitalWrite(13, LOW); | |
Serial.print(0); | |
Serial.print(" "); | |
Serial.print(300); | |
Serial.print(" "); | |
Serial.print(threshold); | |
Serial.print(" "); | |
Serial.println(sampleVal); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment