Created
February 3, 2017 14:07
-
-
Save Caroline13/338f9b915a4ad0dd32d49bbe6c918b25 to your computer and use it in GitHub Desktop.
Code for Pocket Breathalyzer
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 neopixel library) | |
#include <Adafruit_NeoPixel.h> | |
int AnalogPin0 = A0; //gsr pin to A0 | |
int Value; // Data collected into alcohol sensor | |
int Mapped; // Mapped Value variable | |
int minValue = 1023; // Insert minValue from calibration session | |
int maxValue = 0; // tInsert maxValue from calibration session | |
Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, 12, NEO_RGB + NEO_KHZ400); // 14 is the number of neopixels I had | |
void setup() { | |
// initialize pixel strip | |
strip.begin(); | |
// set pixels to off to begin | |
strip.show(); | |
Serial.begin (9600); | |
} | |
void loop() { | |
Value = analogRead(AnalogPin0); // Collect data from GSR | |
// Serial.print ("Original Value = "); � | |
// Serial.println (Value); // Print the Value Data | |
// turn on leds based on value from sensor | |
if (Value <=300 && Value <=349) { | |
strip.setPixelColor(0, 250,0, 0); | |
}else if (Value >= 380) { | |
strip.setPixelColor(0, 0, 255, 0); | |
// }else if (Value > 380) { | |
// strip.setPixelColor(0, 0, 0, 255); | |
strip.show(); | |
delay(500);} | |
else | |
{ strip.setPixelColor(0,250, 0,0); | |
strip.show(); | |
delay(500); } | |
Mapped = map(Value, 0, 1023, 0, 1023); | |
// Serial.print("Mapped Value = ");� | |
// Serial.println(Mapped); | |
Serial.print("Your Sensor Value: "); | |
Serial.println(Value); | |
//delay(500); // Delay of 1/2 second | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment