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)
		
			
				
	
	
		
			21 lines
		
	
	
		
			353 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			353 B
		
	
	
	
		
			Python
		
	
	
	
	
	
from gpiozero import TrafficLights
 | 
						|
from time import sleep
 | 
						|
 | 
						|
lights = TrafficLights(2, 3, 4)
 | 
						|
 | 
						|
lights.green.on()
 | 
						|
 | 
						|
while True:
 | 
						|
    sleep(10)
 | 
						|
    lights.green.off()
 | 
						|
    lights.amber.on()
 | 
						|
    sleep(1)
 | 
						|
    lights.amber.off()
 | 
						|
    lights.red.on()
 | 
						|
    sleep(10)
 | 
						|
    lights.amber.on()
 | 
						|
    sleep(1)
 | 
						|
    lights.green.on()
 | 
						|
    lights.amber.off()
 | 
						|
    lights.red.off()
 |