Herunterladen Inhalt Inhalt Diese Seite drucken

SunFounder Da Vinci Kit Bedienungsanleitung Seite 349

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

if
GPIO.output(row, GPIO.LOW)
pressed_keys
return
################ EXAMPLE CODE START HERE ################
LENS
=
4
password=['1','9','8','4']
testword=['0','0','0','0']
keyIndex=0
def
check():
for
i
in
range(0,LENS):
if(password[i]!=testword[i]):
return
return
1
def
setup():
global
keypad, last_key_pressed
rowsPins
=
[18,23,24,25]
colsPins
=
[10,22,27,17]
keys
=
["1","2","3","A",
"4","5","6","B",
"7","8","9","C",
" *
","0","#","D"]
keypad
=
Keypad(rowsPins, colsPins, keys)
last_key_pressed
LCD1602.init(0x27, 1)
LCD1602.clear()
LCD1602.write(0, 0, 'WELCOME!')
LCD1602.write(2, 1,
time.sleep(2)
def
destroy():
LCD1602.clear()
GPIO.cleanup()
def
loop():
global
keyIndex
global
LENS
global
keypad, last_key_pressed
while(True):
pressed_keys
if
len(pressed_keys)
LCD1602.clear()
LCD1602.write(0, 0,
LCD1602.write(15-keyIndex,1, pressed_keys)
testword[keyIndex]=pressed_keys
keyIndex+=1
if
(keyIndex
if
else:
1.9. 3 Erweiterung
(GPIO.input(col)
==
pressed_keys.append(self.keys[index])
0
=
[]
# init(slave address, background light)
'Enter
password')
=
keypad.read()
!=
0
and
"Enter
is
LENS):
(check()
is
0):
LCD1602.clear()
LCD1602.write(3, 0,
LCD1602.write(0, 1,
LCD1602.clear()
LCD1602.write(4, 0, "CORRECT!")
1):
last_key_pressed
!=
password:")
"WRONG
KEY!")
"please try
again")
SunFounder Da Vinci Kit
(Fortsetzung der vorherigen Seite)
pressed_keys:
(Fortsetzung auf der nächsten Seite)
345

Werbung

Inhaltsverzeichnis
loading

Verwandte Produkte für SunFounder Da Vinci Kit

Diese Anleitung auch für:

Davinci-kit-for-raspberry-pi

Inhaltsverzeichnis