Advertisement
iyera20

Water Level Detection

Jun 22nd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. //www.elegoo.com
  2. //2016.12.9
  3.  
  4. int adc_id = 0;
  5. int HistoryValue = 0;
  6. char printBuffer[128];
  7.  
  8. void setup()
  9. {
  10. Serial.begin(9600);
  11. }
  12.  
  13. void loop()
  14. {
  15. int value = analogRead(adc_id); // get adc value
  16.  
  17. if(((HistoryValue>=value) && ((HistoryValue - value) > 10)) || ((HistoryValue<value) && ((value - HistoryValue) > 10)))
  18. {
  19. sprintf(printBuffer,"ADC%d level is %d\n",adc_id, value);
  20. Serial.print(printBuffer);
  21. HistoryValue = value;
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement