Herunterladen Inhalt Inhalt Diese Seite drucken

SunFounder Da Vinci Kit Bedienungsanleitung Seite 67

Für den raspberry pi 4 modell b, 3 modell a +, 3 modell b +, 3 modell b, 2 modell b, 1 modell b +, 1 modell a +, zero w and zero
Inhaltsverzeichnis

Werbung

segCode
=
[0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,
0x71]
setup():
def
GPIO.setmode(GPIO.BCM)
GPIO.setup(SDI, GPIO.OUT, initial=GPIO.LOW)
GPIO.setup(RCLK, GPIO.OUT, initial=GPIO.LOW)
GPIO.setup(SRCLK, GPIO.OUT, initial=GPIO.LOW)
# Shift the data to 74HC595
def
hc595_shift(dat):
for
bit
in
range(0, 8):
GPIO.output(SDI,
GPIO.output(SRCLK, GPIO.HIGH)
time.sleep(0.001)
GPIO.output(SRCLK, GPIO.LOW)
GPIO.output(RCLK, GPIO.HIGH)
time.sleep(0.001)
GPIO.output(RCLK, GPIO.LOW)
def
main():
while
True:
# Shift the code one by one from segCode list
for
code
in
hc595_shift(code)
print
("segCode[%s]:
double digit HEX to print
time.sleep(0.5)
def
destroy():
GPIO.cleanup()
if
__name__
==
'__main__':
setup()
try:
main()
except
KeyboardInterrupt:
destroy()
Code Erklärung
segCode
=
[0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,
0x71]
Ein Segmentcode-Array von 0 bis F in hexadezimaler Darstellung (gemeinsame Kathode).
def
setup():
GPIO.setmode(GPIO.BCM)
GPIO.setup(SDI, GPIO.OUT, initial=GPIO.LOW)
GPIO.setup(RCLK, GPIO.OUT, initial=GPIO.LOW)
GPIO.setup(SRCLK, GPIO.OUT, initial=GPIO.LOW)
Setzen Sie ds, st_cp, sh_cp auf drei Pins und den Ausgangszustand auf niedrigen Niveau.
GPIO.output(SDI,
0x80
Ordnen Sie die Datendaten SDI (DS) in Bits zu. Hier nehmen wir an, dass dat = 0x3f (0011 1111, wenn Bit = 2, 0x3f
1.7. 1 Ausgabe
0x80
&
(dat
<<
segCode:
0x%02X"%(segCode.index(code), code))
&
(dat
<<
bit))
bit))
SunFounder Da Vinci Kit
(Fortsetzung der vorherigen Seite)
# %02X means
63

Werbung

Inhaltsverzeichnis
loading

Verwandte Produkte für SunFounder Da Vinci Kit

Diese Anleitung auch für:

Davinci-kit-for-raspberry-pi

Inhaltsverzeichnis