Bukisoh

Untitled

Feb 25th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1.  
  2. float vout = 0.0;
  3. float vin = 0.0;
  4. float R1 = 997000.0; // resistance of R1 (100K) -see text!
  5. float R2 = 98500.0;
  6.  
  7.  
  8.  
  9. void setup() {
  10.   
  11.   Serial.begin(9600);
  12. lcd.setcursor(0;0);
  13. lcd.print("Ubat ")
  14. }
  15.  
  16. void loop() {
  17.   
  18.   float value = analogRead(A0);
  19.  
  20.  
  21. vout = (value * 5.0) / 1024.0;  
  22. vin = vout / (R2/(R1+R2));
  23.  
  24.  
  25. Serial.println(vin);
  26.  
  27. vin = vin * 10;
  28. Vin = map(vin, 210, 294 , 0, 100);
  29.  
  30.  
  31. lcd.setcursor(0,5);
  32. lcd.print(vin);
  33.  
  34. }
Add Comment
Please, Sign In to add comment