Reader small image

You're reading from  Practical Python Programming for IoT

Product typeBook
Published inNov 2020
Reading LevelIntermediate
PublisherPackt
ISBN-139781838982461
Edition1st Edition
Languages
Right arrow

Program entry point

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...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Practical Python Programming for IoT
Published in: Nov 2020Publisher: PacktISBN-13: 9781838982461