-
Notifications
You must be signed in to change notification settings - Fork 0
/
countWithDigits.py
44 lines (39 loc) · 974 Bytes
/
countWithDigits.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
import RPi.GPIO as GPIO
import time,sys
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
digits = [0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71 ]
PIN_DATA = 17
PIN_LATCH = 27
PIN_CLOCK = 22
PIN_D1 = 25
PIN_D2 = 24
PIN_D3 = 23
PIN_D4 = 18
GPIO.setup(PIN_D1, GPIO.OUT)
GPIO.setup(PIN_D2, GPIO.OUT)
GPIO.setup(PIN_D3, GPIO.OUT)
GPIO.setup(PIN_D4, GPIO.OUT)
GPIO.setup(PIN_DATA, GPIO.OUT)
GPIO.setup(PIN_LATCH, GPIO.OUT)
GPIO.setup(PIN_CLOCK, GPIO.OUT)
def shiftout(byte):
GPIO.output(PIN_LATCH, 0)
for x in range(8):
GPIO.output(PIN_DATA, (byte >> x) & 1)
GPIO.output(PIN_CLOCK, 1)
GPIO.output(PIN_CLOCK, 0)
GPIO.output(PIN_LATCH, 1)
GPIO.output(PIN_D1, 0)
GPIO.output(PIN_D2, 0)
GPIO.output(PIN_D3, 0)
GPIO.output(PIN_D4, 0)
decimal = 0x80
shiftout(decimal)
time.sleep(3)
#sys.exit("done")
while True:
for x in digits:
shiftout(x)
print(x)
time.sleep(1)