-
Notifications
You must be signed in to change notification settings - Fork 9
/
motor-test.py
52 lines (44 loc) · 1014 Bytes
/
motor-test.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
52
import serial
import time
import RPi.GPIO as GPIO
ChannelPin1 = 4
ChannelPin2 = 17
ChannelPin3 = 27
ChannelPin4 = 22
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(ChannelPin1,GPIO.OUT)
GPIO.setup(ChannelPin2,GPIO.OUT)
GPIO.setup(ChannelPin3,GPIO.OUT)
GPIO.setup(ChannelPin4,GPIO.OUT)
print("init all off")
GPIO.output(ChannelPin1,GPIO.HIGH)
GPIO.output(ChannelPin2,GPIO.HIGH)
GPIO.output(ChannelPin3,GPIO.HIGH)
GPIO.output(ChannelPin4,GPIO.HIGH)
time.sleep(3)
print("LED on")
GPIO.output(ChannelPin1,GPIO.LOW)
time.sleep(3)
print("LED off")
GPIO.output(ChannelPin1,GPIO.HIGH)
time.sleep(2)
print("LED on")
GPIO.output(ChannelPin2,GPIO.LOW)
time.sleep(3)
print("LED off")
GPIO.output(ChannelPin2,GPIO.HIGH)
time.sleep(2)
print("LED on")
GPIO.output(ChannelPin3,GPIO.LOW)
time.sleep(3)
print("LED off")
GPIO.output(ChannelPin3,GPIO.HIGH)
time.sleep(2)
print("LED on")
GPIO.output(ChannelPin4,GPIO.LOW)
time.sleep(3)
print("LED off")
GPIO.output(ChannelPin4,GPIO.HIGH)
time.sleep(2)
GPIO.cleanup()