-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain2b.py
80 lines (71 loc) · 2.21 KB
/
main2b.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# high chip select means writing, low means reading
# clock is negative edged
import RPi.GPIO as GPIO
from time import time
GPIO.setmode(GPIO.BCM)
data_pins = [16, 26, 20, 21, 5, 6, 13, 12, 4, 17, 27, 22]
clock_pin = 23
chip_select = 24
output = 25
GPIO.setwarnings(False)
GPIO.setup(clock_pin, GPIO.OUT)
GPIO.setup(chip_select, GPIO.OUT)
GPIO.setup(output, GPIO.IN)
#Send 12 bits.
GPIO.output(clock_pin, 0)
# set the chip select to write
GPIO.output(chip_select, 1)
# send the bits
GPIO.setup(data_pins, GPIO.OUT)
values=[0,0,0,0,0,0,0,0,0,0,0,0]
GPIO.output(data_pins, values)
raw_input("Press Enter to continue...")
values=[0,1,0,0,0,0,0,0,0,0,0,0]
GPIO.output(data_pins, values)
raw_input("Press Enter to continue...")
values=[0,0,1,0,0,0,0,0,0,0,0,0]
GPIO.output(data_pins, values)
raw_input("Press Enter to continue...")
values=[0,0,0,1,0,0,0,0,0,0,0,0]
GPIO.output(data_pins, values)
raw_input("Press Enter to continue...")
values=[0,0,0,0,1,0,0,0,0,0,0,0]
GPIO.output(data_pins, values)
raw_input("Press Enter to continue...")
values=[0,0,0,0,0,1,0,0,0,0,0,0]
GPIO.output(data_pins, values)
raw_input("Press Enter to continue...")
values=[0,0,0,0,0,0,1,0,0,0,0,0]
GPIO.output(data_pins, values)
raw_input("Press Enter to continue...")
values=[0,0,0,0,0,0,0,1,0,0,0,0]
GPIO.output(data_pins, values)
raw_input("Press Enter to continue...")
values=[0,0,0,0,0,0,0,0,1,0,0,0]
GPIO.output(data_pins, values)
values=[0,0,0,0,0,0,0,0,0,1,0,0]
raw_input("Press Enter to continue...")
GPIO.output(data_pins, values)
raw_input("Press Enter to continue...")
values=[0,0,0,0,0,0,0,0,0,0,1,0]
GPIO.output(data_pins, values)
raw_input("Press Enter to continue...")
values=[0,0,0,0,0,0,0,0,0,0,0,1]
GPIO.output(data_pins, values)
raw_input("Press Enter to continue...")
values=[0,0,0,0,0,0,0,0,0,0,0,0]
GPIO.output(data_pins, values)
raw_input("Press Enter to continue...")
# flash the clock pin
GPIO.output(clock_pin, 1)
GPIO.output(clock_pin, 0)
raw_input("Press Enter to continue...")
values=[1,1,1,1,1,1,1,1,1,1,1,1]
GPIO.output(data_pins, values)
# flash the clock pin
print("get output = clk = 1")
GPIO.output(clock_pin, 1)
print(GPIO.input(output))
raw_input("Press Enter to continue... clk = 0")
GPIO.output(clock_pin, 0)
print(GPIO.input(output))