Menu
Index
Engineering
Entertainment
Literature
Miscellaneous
Contact
Search
tiktok.com/@pkvi.xyz
buymeacoffee.com/pkvi
scored.co/u/pkvi_halfkdeltaxsq
Miter
Why Ayh?
Miter
@pkvi
"...may not meet professional standards."
318 miters
122 tenons
Subscribe
0.00137
Arduino Shades of Grey Water


  1. // Arduino Shades of Grey Water
  2. // pkvi
  3. #include "LiquidCrystal.h"
  4. #include "CapacitiveSensor.h"
  5. LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  6. CapacitiveSensor sinkcap = CapacitiveSensor(6, 7);
  7. const int floatswitch = 8;
  8. const int sinkrelay = 10;
  9. const int tankrelay = 9;
  10. const int sinkled = 14;
  11. const int tankled = 15;
  12. int count = 0;
  13. int floatstate = 0;
  14. int sec = 0;
  15. int lit = 0;
  16. void setup() {
  17. Serial.begin(9600);
  18. pinMode(sinkrelay, OUTPUT);
  19. pinMode(tankrelay, OUTPUT);
  20. pinMode(sinkled, OUTPUT);
  21. pinMode(tankled, OUTPUT);
  22. pinMode(floatswitch, INPUT);
  23. lcd.begin(16, 2);
  24. lcd.print("Initializing...");
  25. delay(100);
  26. lcd.clear();
  27. }
  28. void loop() {
  29. long sinkrun = sinkcap.capacitiveSensor(30);
  30. floatstate = digitalRead(floatswitch);
  31. // Serial.println(sinkrun);
  32. // Serial.println(floatstate);
  33. if (sinkrun > 2500) {
  34. digitalWrite(sinkrelay, HIGH);
  35. digitalWrite(sinkled, HIGH);
  36. } else {
  37. digitalWrite(sinkrelay, LOW);
  38. digitalWrite(sinkled, LOW);
  39. };
  40. if (floatstate == LOW) {
  41. digitalWrite(tankrelay, HIGH);
  42. digitalWrite(tankled, HIGH);
  43. ++count;
  44. } else {
  45. digitalWrite(tankrelay, LOW);
  46. digitalWrite(tankled, LOW);
  47. };
  48. sec = (count / 8);
  49. lit = (count * 0.055);
  50. lcd.setCursor(0, 0);
  51. lcd.print("Seconds");
  52. lcd.setCursor(8, 0);
  53. lcd.print(sec);
  54. //Trouble Shoot Sensor
  55. //lcd.setCursor(12, 0);
  56. //lcd.print(sinkrun);
  57. lcd.setCursor(0, 1);
  58. lcd.print("Liters");
  59. lcd.setCursor(8, 1);
  60. lcd.print(lit);
  61. delay(175);
  62. }