Advertisement
ErnestoGrimes

MinMaxTest

May 20th, 2018
1,477
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   int potPin = 0;
  2.   int potMax = 0;
  3.   int potMin = 1023;
  4.   int potRead;
  5.  
  6. void setup() {
  7.   Serial.begin(19200);
  8. }
  9.  
  10. void loop() {
  11. pot();
  12.  
  13. }
  14.  
  15. void pot() {
  16.   potRead = analogRead(potPin);
  17. //  if ( potRead < potMin) potMin = potRead;
  18. //  if ( potRead > potMax) potMax = potRead;
  19.   potMin = min(potMin,potRead);
  20.   potMax = max(potMax,potRead);
  21.   //hours = map(potRead,potMin,potMax,1,12);
  22.   Serial.print(potRead);
  23.   Serial.print("   ");
  24.   Serial.print(potMin);
  25.   Serial.print("   ");
  26.   Serial.println(potMax);
  27.  
  28. }
Advertisement
RAW Paste Data Copied
Advertisement