musman2015

Untitled

Dec 5th, 2021
626
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from gpiozero import MCP3204
  2. import time
  3. import decimal
  4. import math
  5.  
  6. sensorValue1 = 0
  7. sensorValue2 = 0
  8. crosscount = 0
  9. climb_flag = 0
  10. val=[]
  11. max_v = 0
  12. VmaxD = 0
  13. VeffD = 0
  14. Veff = 0
  15.  
  16. while True:
  17.     for i in range(100):
  18.         v_sensor = MCP3204(channel=1, differential=False)
  19.         sensorValue1 = v_sensor.voltage
  20.         if v_sensor.voltage > 2
  21.             val.append(sensorValue1)
  22.         else:
  23.             val.append(0)
  24.  
  25.     max_v = max(val)
  26.  
  27.     if max_v is not 0:
  28.         VmaxD = max_v
  29.         VeffD = VmaxD / math.sqrt(2)
  30.         Veff = VeffD * 44
  31.     else:
  32.         Veff = 0
  33.     print(f"Voltage: {Veff}")
  34.     VmaxD = 0
RAW Paste Data