Skip to content

Instantly share code, notes, and snippets.

@jedp
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jedp/bb6d658eb02d1156161f to your computer and use it in GitHub Desktop.
Save jedp/bb6d658eb02d1156161f to your computer and use it in GitHub Desktop.
Illuminating one of two LEDs, depending on eTape level
#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