-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_servo.py
47 lines (34 loc) · 1.09 KB
/
test_servo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
""" test_servo.py - Example for the Elegoo 4WD rover MicroPython library
Show how to control the orientation of the ultrasonic sensor (using the Servo).
Remark: the Rover class set the specific calibration data for the Servo
included in the Eleego kit.
You may need to adapt the calibration data when using another servo.
See the rover.servo.calibration() call.
* Author(s): Meurisse D. from MCHobby (shop.mchobby.be).
See project source @ https://github.com/mchobby/micropython-elegoo-4wd
See adapter board: Elegoo-4WD-Pico @ shop.mchobby.be
"""
from rover import Rover
import time
rover=Rover()
# Update servo calibration data
# Parameter are:
# Min pulse time (ms)
# Max pulse time (ms)
# Middle position pulse time (ms)
# Minimum angle value
# Maximum angle value
#
# rover.servo.calibration( 0.7, 2.0, 1.3, 0, 180 )
print( "Look ahead" )
rover.servo.angle( 90 )
time.sleep( 0.1 )
print( "Look right" )
rover.servo.angle( 0 )
time.sleep( 2 )
print( "Look left" )
rover.servo.angle( 180 )
time.sleep(2)
print( "Look ahead" )
rover.servo.angle( 90 )
print( "That s all folks!" )