sdpArray.py 472 B

123456789101112131415161718192021222324
  1. from mcp3008 import MCP3008
  2. import time
  3. class SdpArray():
  4. def __init__(self):
  5. self.adcs = (
  6. MCP3008(0, 0),
  7. MCP3008(0, 1)
  8. )
  9. def getVoltage(self, channel):
  10. if channel < 8:
  11. value = adc[0].read(channel)
  12. else:
  13. value = adc[1].read(channel-8)
  14. voltage = value / 1023.0 * 3.3
  15. return voltage
  16. if __name__ == "__main__":
  17. sdps = SdpArray()
  18. while True:
  19. print("Anliegende Spannung:", sdps.getVoltage(0))
  20. time.sleep(1)