mirror of
				https://github.com/KevinMidboe/python-gpiozero.git
				synced 2025-10-29 17:50:37 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			23 lines
		
	
	
		
			456 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
		
			456 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| from bluedot import BlueDot
 | |
| from gpiozero import Robot
 | |
| from signal import pause
 | |
| 
 | |
| bd = BlueDot()
 | |
| robot = Robot(left=(4, 14), right=(17, 18))
 | |
| 
 | |
| def move(pos):
 | |
|     if pos.top:
 | |
|         robot.forward(pos.distance)
 | |
|     elif pos.bottom:
 | |
|         robot.backward(pos.distance)
 | |
|     elif pos.left:
 | |
|         robot.left(pos.distance)
 | |
|     elif pos.right:
 | |
|         robot.right(pos.distance)
 | |
| 
 | |
| bd.when_pressed = move
 | |
| bd.when_moved = move
 | |
| bd.when_released = robot.stop
 | |
| 
 | |
| pause()
 |