mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2026-01-12 04:15:47 +00:00
Convert recipe examples to includes
Makes it much easier to test things - no copying'n'pasting just run the examples straight from the dir (after wiring stuff up)
This commit is contained in:
12
docs/examples/thermometer.py
Normal file
12
docs/examples/thermometer.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from gpiozero import MCP3008
|
||||
from time import sleep
|
||||
|
||||
def convert_temp(gen):
|
||||
for value in gen:
|
||||
yield (value * 3.3 - 0.5) * 100
|
||||
|
||||
adc = MCP3008(channel=0)
|
||||
|
||||
for temp in convert_temp(adc.values):
|
||||
print('The temperature is', temp, 'C')
|
||||
sleep(1)
|
||||
Reference in New Issue
Block a user