-
Notifications
You must be signed in to change notification settings - Fork 0
/
straightline.py
48 lines (40 loc) · 1.04 KB
/
straightline.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
# Import the build in libraries for the script
import time
import os
# Import the motor library file which allows control of the motors
import MotorLibrary
# Define the pins which will be used to drive the motors
PINS = {
"frf" : 40,
"frb" : 38,
"flf" : 32,
"flb" : 36,
"brf" : 37,
"brb" : 35,
"blf" : 22,
"blb" : 33
}
# Define the pins which are used to manage the motor speed
PWMS = {
"l" : 16,
"r" : 18
}
# Create an instance of the motor library
MOTORS = MotorLibrary.management(PINS, PWMS)
# Enable the motors at full power going forwards
MOTORS.move(0.87, 1)
# Open a try statement which allows for clean exit upon Ctrl+C
try:
# Loop the time sleep so the motors run constantly
while True:
time.sleep(0.1)
# Wait for the Ctrl+C Input then stop all motors and close the script
except KeyboardInterrupt:
# Stop motors and cleanup the GPIO pins
MOTORS.stop()
MOTORS.cleanup()
# Display Debug Information
os.system("clear")
print ("Exiting")
# Quit program
exit(0)