Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- value_VOLTMETRO = analogRead(VOLTMETRO_INPUT);
- vout_VOLTMETRO = (value_VOLTMETRO * 5.11) / 1023.0;
- // insert instead of 5.0V the voltage output between the 5V and GND pins of your Arduino
- // vin_VOLTMETRO = vout_VOLTMETRO x CALIBRATION VALUE; THE CALIBRATION VALUE
- // is GIVEN BY TOTAL VOLTAGE / VOLTAGE ON THE 2nd RESISTANCE, OR (V ON THE TOTAL RESISTANCE R1 + R2) / V ON THE R2
- // 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
- vin_VOLTMETRO = vout_VOLTMETRO * 10.8947;
- if (vin_VOLTMETRO < 0.09) {
- vin_VOLTMETRO = 0.0;
- }
- NxSerial.write("t25.txt=");// puts calculated Voltage (float) in text-field t3.txt
- NxSerial.write(0x22);
- NxSerial.print(vin_VOLTMETRO, 2); // valore a 2 cifre decimali
- NxSerial.write(0x22);
- NxSerial.write(0xff);
- NxSerial.write(0xff);
- NxSerial.write(0xff);
- Serial.println("-------------------------------");
- Serial.println("");
- Serial.print("VOLTMETRO: ");
- Serial.print(vin_VOLTMETRO, 2);
- Serial.println(" V");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement