Dashboard Keyboard With LCD Display and Arduino Uno

About: Do you like technology? Follow my channel on Youtube and my Blog. In them I put videos every week of microcontrollers, arduinos, networks, among other subjects. New tutorials on Tuesdays and Fridays.

This is a matrix keyboard running along with an LCD display and an Arduino Uno, the most basic that exists today. The purpose of this setup is to create a program that receives a password typed on the matrix keyboard, compares it with the correct password, and displays a confirmation message on the display.

It is important to remember that both the matrix keyboard and this display work with ESP8266 and ESP32.

As you can see, we power the circuit with the Arduino with a USB, since we are not using an external source. Eight wires connected in a very simple way to the Arduino’s ports make the connection of our keyboard. This keyboard has no power and is passive, which greatly facilitates the connections.

The display is connected with an Arduino via the UART, the serial port, which also powers the device.

In a demonstration, we show in the video our circuit checking if the password typed on the keyboard is correct or not.

In the PDF used in the video and available here, we have the complete pinout of the chip being used.

Step 1: Serial Display

This is the serial display that communicates with the UART, which is RS with a TXRX. It also exists in I2C versions, but other models will remain for an upcoming assembly. In this case, this display works by the UART by RS.

Step 2: Matrix Keyboard

The example of the matrix keyboard that we use is that of the photo, and it is on the right side. We have a diagram that shows how it works. It actually only has 4x4 lines. Thus, it uses the minimum amount of wires; one wire for each row and column, so that there are eight wires in total.

It doesn’t need power because it works as follows: when the 7 is pressed, the keyboard picks up the 7 and connects to the line and column, which makes identification possible by scanning the algorithm automatically.

It is important to remember that any 4x4 keyboard that is dot matrix will work in this assembly.

Step 3: Assembly

In the general scheme, we connect eight wires directly to the Arduino's ports, since the keyboard has no power. In the display, we have a signal of RS 232, and positive and negative power. The Backlight is still present, which is also already connected (identified by BKL).

Step 4: Source Code

In the source code of this project, you have to include the serial and keypad. It has a set RX_PIN and a TX_PIN, necessary for the serial software, and also the INVERTED 1. This was placed underneath to amplify the signal that uses input with inverted logic.

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

Step 5: Display Commands

Important: In this display, it isn’t enough to just put a string on it. You need to send control characters. The PDF contains the link of the site where you have a manual of this display. But if you have a serial display of another brand, it is good to look at their control codes that pertain to this. In this model, for example, when we send a certain control (information for this display, for example), we need to send a prefix, the number 254, to enable communication.

So we set up an ARRAY to facilitate things, which is a collection of variables that are accessed with a numeric index. This will be sent to the display as an initial configuration.

//comando para limpar toda a tela do display
const 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};

Step 6: Keyboard Operation

How does the keyboard function? First, it mounts an array. This array is of the character that will actually be displayed there. So if I put an X, when I press the first left button at the top, it is displayed. This is the content of the keyboard, which is what it will command.

Other things we have the definition for are row number 4 and column number 4, in the case of the ARRAY of this keyboard. We still have pins of the lines, which are the Arduino pins, and the pins of the column. We still have a customKeypad Keypad builder with the symbol, pin, row, and column parameters.

const byte LINHAS = 4; //número de linhas do teclado
const byte COLUNAS = 4; //número de colunas do teclado //define 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( makeKeymap(SIMBOLOS), PINOS_LINHA, PINOS_COLUNA, LINHAS, COLUNAS);

Step 7: Password Setting

In this part, we define the password, and then we need to enter a password, which is an empty string. Below, we put the instance of the softwareSerial.

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

Step 8: Setup

As for the Setup, here is the displaySerial.begin (2,400), which is about the speed. In our case, this is enough to send a byte. Following this, there is a wait of 700 milliseconds. We include the displaySerial.print (initialConfig) from the initial configuration with a new delay of 10 milliseconds, and we go to the start function. In the start function, we put displaySerial.print ("password:").

void setup(){
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 a configuração inicial do display displaySerial.print(configInicial); delay(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:"); }

Step 9: Loop

In the loop, we create a customKey = customKeypad.getKey (), and in the sequence, we enter a Switch command.

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

Loop Switch Part 1

Inside the Switch command: it shows the list of possibilities of printable keys, if pressed, and increments the password: takes the customKey and concatenates the entered password. Next, the displaySerial.print (customKey) shows the key contents.

switch(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); break;

Loop Switch Part 2

In this code, we show a scenario for if the CLEAR key is pressed. If you type the letter C and clear the variable that holds the password you are typing, then it calls the command to clear the screen and restarts.

//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); //configura a mensagem para digitar a senha inicio(); break;

Loop Switch Part 3

Another possibility is if you type the letter E. In this case, the screen will be cleaned and analyzed if the password entered is correct or incorrect. Next, we will give a new delay of 2 seconds, clear the screen, reset the password variable, and return to the beginning.

//caso a tecla ENTER seja pressionada, devemos comparar as senhas
case 'e': //limpa a tela displaySerial.print(limparTela); //se a senha digitada foi igual a ESPERADA if(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 delay(2000); displaySerial.print(limparTela);

Share

    Recommendations

    • Toys Contest

      Toys Contest
    • PCB Contest

      PCB Contest
    • Make it Glow Contest 2018

      Make it Glow Contest 2018

    Discussions