mathiaspl20

Untitled

Nov 10th, 2017
101
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int analogPin= 0;
  2. int count =0;
  3. int raw= 0;
  4. int Vin= 5;
  5. int before=0;
  6. float Vout= 0;
  7. float R1= 1000;
  8. float R2= 0;
  9. float buffer= 0;
  10.  
  11. void setup()
  12. {
  13. Serial.begin(9600);
  14. }
  15.  
  16. void loop()
  17. {
  18. raw= analogRead(analogPin);
  19. if(raw)
  20. {
  21. buffer= raw * Vin;
  22. Vout= (buffer)/1024.0;
  23. buffer= (Vin/Vout) -1;
  24. R2= R1 * buffer;
  25. if (R2< 200000) {
  26. count++;
  27. Serial.println("---------");
  28. Serial.print("count number: ");
  29. Serial.println(count);
  30. Serial.print("R2: ");
  31. Serial.print(R2);
  32. Serial.println();
  33. }
  34. }
  35. }
RAW Paste Data