123456789101112131415161718192021222324 |
- from mcp3008 import MCP3008
- import time
- class SdpArray():
- def __init__(self):
- self.adcs = (
- MCP3008(0, 0),
- MCP3008(0, 1)
- )
- def getVoltage(self, channel):
- if channel < 8:
- value = adc[0].read(channel)
- else:
- value = adc[1].read(channel-8)
- voltage = value / 1023.0 * 3.3
- return voltage
- if __name__ == "__main__":
- sdps = SdpArray()
- while True:
- print("Anliegende Spannung:", sdps.getVoltage(0))
- time.sleep(1)
|