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)
		
			
				
	
	
		
			24 lines
		
	
	
		
			388 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			388 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| from gpiozero import LED, Buzzer, Button
 | |
| from signal import pause
 | |
| 
 | |
| button = Button(2)
 | |
| buzzer = Buzzer(3)
 | |
| red = LED(4)
 | |
| amber = LED(5)
 | |
| green = LED(6)
 | |
| 
 | |
| things = [red, amber, green, buzzer]
 | |
| 
 | |
| def things_on():
 | |
|     for thing in things:
 | |
|         thing.on()
 | |
| 
 | |
| def things_off():
 | |
|     for thing in things:
 | |
|         thing.off()
 | |
| 
 | |
| button.when_pressed = things_on
 | |
| button.when_released = things_off
 | |
| 
 | |
| pause()
 |