Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement