-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.py
More file actions
36 lines (28 loc) · 716 Bytes
/
test.py
File metadata and controls
36 lines (28 loc) · 716 Bytes
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
from gpiozero import OutputDevice, PWMOutputDevice
from time import sleep
# Define the GPIO pins
PUL_PIN = 13
DIR_PIN = 6
ENA_PIN = 12
# Initialize the pins as output devices
pul = PWMOutputDevice(PUL_PIN, active_high=True, frequency=100)
dir = OutputDevice(DIR_PIN, active_high=True)
ena = OutputDevice(ENA_PIN, active_high=False)
# Enable the driver
ena.on()
sleep(1)
# Test the movement with CW (Clockwise)
print("Starting CW rotation...")
dir.off()
pul.pulse(n=200, background=False)
sleep(1)
# Test the movement with CCW (Counter-Clockwise)
print("Starting CCW rotation...")
dir.on()
pul.pulse(n=200, background=False)
# End of test
print("Test complete.")
# Cleanup
pul.close()
dir.close()
ena.close()