Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #define ETAPE A0
  2.  
  3. // Set crucial level as appropriate for your needs.
  4. // For me, 687 indicates three inches of water.
  5. #define CRUCIAL_LEVEL 687
  6. #define LED_RED 13
  7. #define LED_GREEN 12
  8.  
  9. float resistance;
  10.  
  11. void setup(void) {
  12. pinMode(LED_RED, OUTPUT);
  13. pinMode(LED_GREEN, OUTPUT);
  14. Serial.begin(9600);
  15. }
  16.  
  17. void loop(void) {
  18. resistance = analogRead(ETAPE);
  19. Serial.println(resistance);
  20.  
  21. if (resistance > CRUCIAL_LEVEL) {
  22. glowRed();
  23. } else {
  24. glowGreen();
  25. }
  26.  
  27. delay(1000);
  28. }
  29.  
  30. void glowRed() {
  31. digitalWrite(LED_RED, HIGH);
  32. digitalWrite(LED_GREEN, LOW);
  33. }
  34.  
  35. void glowGreen() {
  36. digitalWrite(LED_GREEN, HIGH);
  37. digitalWrite(LED_RED, LOW);
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement