mirror of
				https://github.com/KevinMidboe/python-gpiozero.git
				synced 2025-10-29 17:50:37 +00:00 
			
		
		
		
	Makes it much easier to test things - no copying'n'pasting just run the examples straight from the dir (after wiring stuff up)
		
			
				
	
	
		
			13 lines
		
	
	
		
			259 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			13 lines
		
	
	
		
			259 B
		
	
	
	
		
			Python
		
	
	
	
	
	
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)
 |