-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpolkarobot.py
52 lines (39 loc) · 1018 Bytes
/
polkarobot.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
48
49
50
51
#!/usr/bin/python
from Stepper import Motor
from time import sleep
import RPi.GPIO as GPIO
import sys
import datetime
#import thread
import threading
class MotorThread(threading.Thread):
def __init__(self, pin1, pin2, pin3, pin4, command_index):
threading.Thread.__init__(self)
self.pin1 = int(pin1)
self.pin2 = int(pin2)
self.pin3 = int(pin3)
self.pin4 = int(pin4)
self.command_index = int(command_index)
self.motor = Motor([int(self.pin1), int(self.pin2), int(self.pin3), int(self.pin4)], 15)
def run(self):
self.motor.move_to(90)
if __name__ == "__main__":
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
try:
mFL = MotorThread( 8, 10, 12, 16, 1)
mFR = MotorThread(18, 22, 24, 26, 2)
mBL = MotorThread( 3, 5, 7, 11, 3)
mBR = MotorThread(15, 19, 21, 23, 4)
mFL.start()
mFR.start()
mBL.start()
#mBR.start()
except Exception as inst:
print("Error: unable to start thread")
print(type(inst))
print(inst.args)
print(inst)
while True:
pass
GPIO.cleanup()