-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestPWNMotor.py
50 lines (40 loc) · 910 Bytes
/
TestPWNMotor.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
#!/usr/bin/env python
# Respond to keyboard/remote and light leds in response
import RPi.GPIO as GPIO
import time
PIN_in1 = 13
PIN_in2 = 19
PIN_in3 = 17
PIN_in4 = 04
try:
GPIO.setmode(GPIO.BCM)
GPIO.setup(PIN_in1, GPIO.OUT)
GPIO.setup(PIN_in2, GPIO.OUT)
GPIO.setup(PIN_in3, GPIO.OUT)
GPIO.setup(PIN_in4, GPIO.OUT)
print ("Motor B Direction one")
motorAFwd = GPIO.PWM(PIN_in1, 100)
motorABack = GPIO.PWM(PIN_in2, 100)
motorBFwd = GPIO.PWM(PIN_in3, 100)
motorBBack = GPIO.PWM(PIN_in4, 100)
print ('start it now')
motorBFwd.start(100)
motorAFwd.start(100)
time.sleep(4)
print ('Turn it down')
motorAFwd.start(10)
motorBFwd.start(50)
time.sleep(4)
motorAFwd.start(0)
motorBFwd.start(0)
time.sleep(2)
motorABack.start(10)
motorBBack.start(100)
time.sleep(5)
motorABack.stop()
motorBBack.stop()
print('stopped')
GPIO.cleanup()
except:
KeyboardInterrupt
GPIO.cleanup()