Advertisement
Guest User

VOLMETRE CODCE

a guest
Jan 26th, 2020
472
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. value_VOLTMETRO = analogRead(VOLTMETRO_INPUT);
  2.  
  3. vout_VOLTMETRO = (value_VOLTMETRO * 5.11) / 1023.0;
  4. // insert instead of 5.0V the voltage output between the 5V and GND pins of your Arduino
  5.  
  6.  
  7. // vin_VOLTMETRO = vout_VOLTMETRO x CALIBRATION VALUE; THE CALIBRATION VALUE
  8. // is GIVEN BY TOTAL VOLTAGE / VOLTAGE ON THE 2nd RESISTANCE, OR (V ON THE TOTAL RESISTANCE R1 + R2) / V ON THE R2
  9. // in this case V TOT is 12.42V, while V on R2 is 0.64V so the CALIBRATION VAL is 12.42 / 0.64 = 19.40
  10.  
  11. vin_VOLTMETRO = vout_VOLTMETRO * 10.8947;
  12.  
  13.  
  14. if (vin_VOLTMETRO < 0.09) {
  15. vin_VOLTMETRO = 0.0;
  16. }
  17.  
  18. NxSerial.write("t25.txt=");// puts calculated Voltage (float) in text-field t3.txt
  19. NxSerial.write(0x22);
  20. NxSerial.print(vin_VOLTMETRO, 2); // valore a 2 cifre decimali
  21. NxSerial.write(0x22);
  22. NxSerial.write(0xff);
  23. NxSerial.write(0xff);
  24. NxSerial.write(0xff);
  25.  
  26.  
  27. Serial.println("-------------------------------");
  28. Serial.println("");
  29. Serial.print("VOLTMETRO: ");
  30. Serial.print(vin_VOLTMETRO, 2);
  31. Serial.println(" V");
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement