Last active
August 29, 2015 14:11
-
-
Save jedp/bb6d658eb02d1156161f to your computer and use it in GitHub Desktop.
Illuminating one of two LEDs, depending on eTape level
This file contains hidden or 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
#define ETAPE A0 | |
// Set crucial level as appropriate for your needs. | |
// For me, 687 indicates three inches of water. | |
#define CRUCIAL_LEVEL 687 | |
#define LED_RED 13 | |
#define LED_GREEN 12 | |
float resistance; | |
void setup(void) { | |
pinMode(LED_RED, OUTPUT); | |
pinMode(LED_GREEN, OUTPUT); | |
Serial.begin(9600); | |
} | |
void loop(void) { | |
resistance = analogRead(ETAPE); | |
Serial.println(resistance); | |
if (resistance > CRUCIAL_LEVEL) { | |
glowRed(); | |
} else { | |
glowGreen(); | |
} | |
delay(1000); | |
} | |
void glowRed() { | |
digitalWrite(LED_RED, HIGH); | |
digitalWrite(LED_GREEN, LOW); | |
} | |
void glowGreen() { | |
digitalWrite(LED_GREEN, HIGH); | |
digitalWrite(LED_RED, LOW); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment