Cov txheej txheem:

Dashboard Keyboard Nrog LCD Zaub thiab Arduino Uno: 9 Cov Kauj Ruam
Dashboard Keyboard Nrog LCD Zaub thiab Arduino Uno: 9 Cov Kauj Ruam

Video: Dashboard Keyboard Nrog LCD Zaub thiab Arduino Uno: 9 Cov Kauj Ruam

Video: Dashboard Keyboard Nrog LCD Zaub thiab Arduino Uno: 9 Cov Kauj Ruam
Video: Windows 10/11 Black Screen With Cursor [Solved] 2024, Lub Xya hli ntuj
Anonim
Image
Image
Dashboard Keyboard Nrog LCD Zaub thiab Arduino Uno
Dashboard Keyboard Nrog LCD Zaub thiab Arduino Uno
Dashboard Keyboard Nrog LCD Zaub thiab Arduino Uno
Dashboard Keyboard Nrog LCD Zaub thiab Arduino Uno

Qhov no yog cov keyboard matrix ua haujlwm nrog rau cov duab LCD thiab Arduino Uno, qhov yooj yim tshaj plaws uas muaj nyob niaj hnub no. Lub hom phiaj ntawm kev teeb tsa no yog txhawm rau tsim qhov program uas tau txais tus password nkag mus rau ntawm cov keyboard matrix, sib piv nws nrog tus password raug, thiab qhia cov lus lees paub ntawm lub vijtsam.

Nws yog ib qho tseem ceeb kom nco ntsoov tias ob lub keyboard matrix thiab cov zaub no ua haujlwm nrog ESP8266 thiab ESP32.

Raws li koj tuaj yeem pom, peb ua lub zog txuas nrog Arduino nrog USB, vim peb tsis siv lwm qhov chaw. Yim txoj hlua txuas nrog hauv txoj hauv kev yooj yim heev rau Arduino cov chaw nres nkoj ua kev sib txuas ntawm peb cov keyboard. Cov keyboard no tsis muaj hwj chim thiab tsis muaj zog, uas pab txhawb kev sib txuas.

Cov zaub tau txuas nrog Arduino ntawm UART, qhov chaw nres nkoj txuas, uas tseem ua rau lub zog ntaus ntawv.

Hauv kev ua qauv qhia, peb pom hauv cov vis dis aus peb saib xyuas lub voj voog yog tias tus password nkag rau ntawm cov keyboard raug lossis tsis raug.

Hauv PDF siv hauv daim vis dis aus thiab muaj nyob ntawm no, peb muaj qhov ua tiav pinout ntawm lub nti tau siv.

Kauj ruam 1: Serial Zaub

Serial Zaub
Serial Zaub
Zaub Zaub
Zaub Zaub

Nov yog cov lus qhia uas txuas nrog UART, uas yog RS nrog TXRX. Nws kuj tseem muaj nyob hauv I2C cov qauv, tab sis lwm cov qauv yuav nyob twj ywm rau kev sib dhos yav tom ntej. Hauv qhov no, cov zaub no ua haujlwm los ntawm UART los ntawm RS.

Kauj ruam 2: Matrix Keyboard

Matrix Keyboard Cov
Matrix Keyboard Cov

Piv txwv ntawm cov keyboard matrix uas peb siv yog ntawm daim duab, thiab nws nyob ntawm sab xis. Peb muaj daim duab qhia pom tias nws ua haujlwm li cas. Qhov tseeb nws tsuas muaj 4x4 kab. Yog li, nws siv qhov tsawg kawg ntawm cov xov hlau; ib lub xaim rau txhua kab thiab kab, yog li ntawd muaj yim kab nyob hauv tag nrho.

Nws tsis xav tau lub zog vim nws ua haujlwm raws li hauv qab no: thaum 7 raug nias, cov keyboard khaws 7 thiab txuas rau kab thiab kab ntawv, uas ua rau kev txheeb xyuas tau los ntawm kev txheeb xyuas qhov txheej txheem.

Nws yog ib qho tseem ceeb kom nco ntsoov tias ib qho 4x4 keyboard uas yog dot matrix yuav ua haujlwm hauv kev sib dhos no.

Kauj ruam 3: Sib dhos

Los ua ke
Los ua ke

Hauv cov txheej txheem dav dav, peb txuas yim lub xov hlau ncaj qha mus rau Arduino cov chaw nres nkoj, vim cov keyboard tsis muaj hwj chim. Hauv cov zaub, peb muaj lub teeb liab ntawm RS 232, thiab lub zog zoo thiab tsis zoo. Backlight tseem nyob tam sim no, uas tseem tau txuas nrog (txheeb xyuas los ntawm BKL).

Kauj ruam 4: Source Code

Hauv qhov chaws ntawm qhov haujlwm no, koj yuav tsum suav nrog cov lej thiab cov keyboard. Nws muaj teeb tsa RX_PIN thiab TX_PIN, tsim nyog rau cov lej software, thiab tseem INVERTED 1. Qhov no tau muab tso rau hauv qab kom nthuav dav lub teeb liab uas siv cov lus nkag nrog cov lus tsis sib thooj.

// biblioteca responsável pela comunicação com o display LCD #include // biblioteca responsável por capturar a tecla que foi pressionada no teclado #include // pino invalido apenas usado no contrutor do SoftwareSerial #define RX_PIN 255 // pino TX da nossa ligação Arduino x Zaub LCD #define TX_PIN 3 // inverte a lógica dos pinos Rx e Tx, tratando LOW como HIGH e vice-versa #define INVERTED 1

Kauj ruam 5: Zaub Commands

Cov lus txib
Cov lus txib

Tseem ceeb: Hauv cov zaub no, nws tsis txaus los tsuas yog muab hlua rau nws. Koj yuav tsum xa cov cim tswj. PDF muaj qhov txuas ntawm lub xaib uas koj muaj phau ntawv qhia ntawm cov zaub no. Tab sis yog tias koj muaj cov ntawv tso tawm ntawm lwm lub npe, nws yog qhov zoo los saib lawv cov lej tswj hwm uas cuam tshuam txog qhov no. Hauv cov qauv no, piv txwv li, thaum peb xa qee yam kev tswj hwm (cov ntaub ntawv rau cov zaub no, piv txwv), peb yuav tsum xa ua ntej, tus lej 254, kom muaj kev sib txuas lus.

Yog li peb teeb tsa ARRAY los pab txhawb tej yam, uas yog sau los ntawm cov kev hloov pauv uas tau nkag mus nrog tus lej lej. Qhov no yuav raug xa mus rau cov zaub raws li kev teeb tsa thawj zaug.

// comando para limpar toda a tela do displayconst char limparTela = {254, 1}; // comandos de configuração inicial/ * 254, 254 acende o backlight 254, 1 limpa a tela 254, 253, 1 configura o contraste em nível alto 254, 13 liga o cursor paraficar piscando */const char configInicial = {254, 254, 254, 1, 254, 253, 1, 254, 13};

Kauj Ruam 6: Kev Ua Haujlwm Keyboard

Cov keyboard ua haujlwm li cas? Ua ntej, nws mount ib array. Cov kab no yog ntawm tus yam ntxwv uas yuav tshwm sim nyob rau ntawd. Yog li yog tias kuv tso tus X, thaum kuv nias thawj zaug khawm sab saum toj, nws tau tshwm. Nov yog cov ntsiab lus ntawm cov keyboard, uas yog yam nws yuav hais kom ua.

Lwm yam peb muaj lub ntsiab lus rau yog kab zauv 4 thiab kab zauv 4, hauv qhov ARRAY ntawm cov keyboard no. Peb tseem muaj tus pin ntawm kab, uas yog Arduino pins, thiab tus pin ntawm kab ntawv. Peb tseem muaj tus kheej tsim Keypad Keypad tus tsim nrog lub cim, tus lej, kab, thiab kab lus tsis.

const byte LINHAS = 4; // número de linhas do tecladoconst byte COLUNAS = 4; // número de colunas do teclado // txhais uma matriz com os símbolos que deseja ser lido do teclado char SIMBOLOS [LINHAS] [COLUNAS] = {{'A', '1', '2', '3'}, { 'B', '4', '5', '6'}, {'C', '7', '8', '9'}, {'D', 'c', '0', 'e '}}; byte PINOS_LINHA [LINHAS] = {8, 9, 10, 11}; // pinos que indicam as linhas do teclado byte PINOS_COLUNA [COLUNAS] = {4, 5, 6, 7}; // pinos que indicam as colunas do teclado // instancia de Keypad, responsável por capturar a tecla pressionada Keypad customKeypad = Keypad (uaKeymap (SIMBOLOS), PINOS_LINHA, PINOS_COLUNA, LINHAS, COLUNAS);

Kauj Ruam 7: Teeb Tus password

Hauv ntu no, peb piav qhia tus password, thiab tom qab ntawd peb yuav tsum nkag mus rau tus password, uas yog txoj hlua khoob. Hauv qab no, peb muab piv txwv ntawm softwareSerial.

// variáveis resposnsáveis por armazenar as senhasconst String SENHA_ESPERADA = "1234ABCD"; Txoj hlua SENHA_DIGITADA = ""; // instancia de SoftwareSerial para nos comunicar com o Display via serial SoftwareSerial displaySerial = SoftwareSerial (RX_PIN, TX_PIN, INVERTED);

Kauj ruam 8: Teeb tsa

Raws li teeb tsa, ntawm no yog displaySerial.begin (2, 400), uas yog hais txog qhov nrawm. Hauv peb qhov xwm txheej, qhov no txaus los xa ib byte. Ua raws li qhov no, tau tos txog 700 milliseconds. Peb suav nrog displaySerial.print (initialConfig) los ntawm kev teeb tsa thawj zaug nrog ncua sijhawm tshiab ntawm 10 milliseconds, thiab peb mus rau qhov pib ua haujlwm. Hauv qhov pib ua haujlwm, peb tso displaySerial.print ("password:").

teeb tsa tsis muaj dab tsi () {Serial.begin (2400); // inicializando a serial de comunicação com o display // importante o baud rate ser de 2400 displaySerial.begin (2400); // tempo de espera pela inicialização do display delay (700); // seta configuração inicial ua zaub displaySerial.print (configInicial); ncua (10); inicio (); } // função responsável por imprimir na tela a mensagem para digitar a senha // é chamada toda vez q a senha foi digitada e comparada, também quando // a tecla limpar display foi pressionada. void inicio () {displaySerial.print ("Senha:"); }

Kauj ruam 9: Loop

Hauv lub voj, peb tsim tus customKey = customKeypad.getKey (), thiab hauv ntu, peb nkag mus rau Switch hais kom ua.

// captura a tecla pressionada do teclado char customKey = customKeypad.getKey (); // caso alguma tecla foi pressionada yog (customKey) {Serial.println (customKey); hloov (customKey) { /… /}}

Loop Hloov Tshooj 1

Sab hauv Hloov cov lus txib: nws qhia cov npe muaj peev xwm ntawm cov yuam sij luam tawm, yog tias nias, thiab nce tus password: siv tus kheejKey thiab sib txuas tus lej nkag mus. Tom ntej no, displaySerial.print (customKey) qhia cov ntsiab lus tseem ceeb.

hloov (customKey) {// caso alguma das teclas imprimíveis foi pressionada case 'A': case 'B': case 'C': case 'D': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': // concatena o novo símbolo a senha que estamos digitando SENHA_DIGITADA+= customKey; Serial.println (SENHA_DIGITADA); // imrpime na tela o símbolo pressionado displaySerial.print (customKey); tawg;

Loop Hloov Tshooj 2

Hauv txoj cai no, peb qhia qhov xwm txheej yog tias CLEAR qhov tseem ceeb raug nias. Yog tias koj ntaus ntawv C thiab tshem qhov sib txawv uas tuav tus password koj tab tom ntaus, tom qab ntawd nws hu cov lus txib kom tshem lub vijtsam thiab rov pib dua.

// caso a tecla CLEAR tenha sido pressionada case 'c': // limpa a variável que guarda a senha que está sendo digitada SENHA_DIGITADA = ""; // chama o comando para limpar a tela displaySerial.print (limparTela); // teeb tsa cov kab lus rau digitar hauv senha inicio (); tawg;

Loop Hloov Tshooj 3

Lwm qhov muaj peev xwm yog tias koj ntaus ntawv E. Hauv qhov no, lub vijtsam yuav raug ntxuav thiab tshuaj xyuas yog tias tus password nkag mus raug lossis tsis raug. Tom ntej no, peb yuav muab ncua sijhawm ncua ntawm 2 vib nas this, tshem tawm lub vijtsam, rov pib dua tus lej hloov pauv, thiab rov qab mus rau qhov pib.

// caso a tecla ENTER seja pressionada, devemos comparar as senhas case 'e': // limpa a tela displaySerial.print (limparTela); // se senha digitada foi igual ESPERADA yog (SENHA_ESPERADA == SENHA_DIGITADA) {Serial.println ("Senha Correta!"); // imprime mensagem de senha correta displaySerial.print ("Senha Correta !!!"); } // caso senha esteja errada else {Serial.println ("Senha Incorreta!"); // imprime mensagem de senha incorreta displaySerial.print ("Senha Incorreta!"); } // aguarda 2 segundos para limpar a tela novamente e esperar uma nova senha ser digitada ncua (2000); displaySerial.print (limparTela);

Pom zoo: