Our program continuously loops, reading our analog input values for each pot and prints formatted output to the Terminal.
At line (5), we see how to access the integer value from the frequency pot using frequency_ch.valueĀ and the voltage value using frequency_ch.voltage:
if __name__ == '__main__':
try:
while True:
output = ("Frequency Pot (A0) value={:>5} volts={:>5.3f} "
"Duty Cycle Pot (A1) value={:>5} volts={:>5.3f}")
output = output.format(frequency_ch.value, # (5)
frequency_ch.voltage,
duty_cycle_ch.value,
duty_cycle_ch.voltage)
print(output)
sleep(0.05)
except KeyboardInterrupt:
i2c.deinit() # (6)
Finally, notice that the program is wrapped in a try/except block that will captureĀ Ctrl...