-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestMotor1.py
More file actions
46 lines (41 loc) · 1.57 KB
/
Copy pathTestMotor1.py
File metadata and controls
46 lines (41 loc) · 1.57 KB
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
from lx16a import *
from math import sin, cos
import time
# This is the port that the controller board is connected to
# This will be different for different computers
# On Windows, try the ports COM1, COM2, COM3, etc...
# On Raspbian, try each port in /dev/
LX16A.initialize("COM9")
# There should two servos connected, with IDs 1 and 2
servo1 = LX16A(7)
t = 0
flag = True
while flag:
# Two sine waves out of phase
# The servos can rotate between 0 and 240 degrees,
# So we adjust the waves to be in that range
#servo1.moveTimeWrite(sin(t) * 120 + 120)
print("Motor id is ", servo1.IDRead())
print("Angle offset is ", servo1.angleOffsetRead())
print("Angle limit is ", servo1.angleLimitRead())
print("Physical pos is ", servo1.getPhysicalPos());
print("Virtual pos is ", servo1.getVirtualPos());
print("Current temperature is ", servo1.tempRead())
print("Current voltage is ", servo1.vInRead())
servo1.moveTimeWriteRel(30, time = 1000)
servo1.angleOffsetWrite()
print("Angle offset is ", servo1.angleOffsetRead())
print("Physical pos is ", servo1.getPhysicalPos());
print("Virtual pos is ", servo1.getVirtualPos());
print("Current temperature is ", servo1.tempRead())
print("Current voltage is ", servo1.vInRead())
time.sleep(2)
servo1.moveTimeWriteRel(-30, time = 1000)
servo1.angleOffsetWrite()
print("Angle offset is ", servo1.angleOffsetRead())
print("Physical pos is ", servo1.getPhysicalPos());
print("Virtual pos is ", servo1.getVirtualPos());
print("Current temperature is ", servo1.tempRead())
print("Current voltage is ", servo1.vInRead())
t += 0.01
flag = False