#include <Adafruit_GFX.h> //
#include <Adafruit_ST7789.h> //LCD Display lib
#include <SPI.h> //
#include <Keypad.h> //Keypad lib
using namespace std;
//KeyPad Init..
const byte ROWS = 4;
const byte COLS = 4;
char hexaKeys[ROWS][COLS] =
{
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {12, 14, 27, 26};
byte colPins[COLS] = {25, 33, 32, 35};
Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
//Dispay Init..
#define CS 5
#define RST 15
#define DC 4
#define MOSI 23 //DIN
#define SCLK 18 //CLK
#define MISO 19 //BL
Adafruit_ST7789 LCD = Adafruit_ST7789(CS, DC, RST);
void setup()
{
Serial.begin(9600);
LCD.init(240, 320);
LCD.setRotation(1);
LCD.fillScreen(ST77XX_BLACK);
LCD.setTextColor(ST77XX_GREEN);
LCD.setTextSize(3);
LCD.setCursor(0, 0);
LCD.println("Welcome to General Election!!");
}
void loop()
{
delay(1000);
}
void loop1()
{
LCD.fillScreen(ST77XX_BLACK);
LCD.setCursor(0, 0);
LCD.println("Welcome to General Election!!");
LCD.println("Please enter '#' to start..");
char startKey = customKeypad.getKey();
if(startKey == '#')
{
Start:
LCD.fillScreen(ST77XX_BLACK);
LCD.println("Enter user ID number and press '#'");
string idNumber = "";
char idNumberKey = customKeypad.getKey();
while(idNumberKey == '#' )
{
if(idNumberKey != '\0')
idNumber += idNumberKey;
LCD.print(idNumberKey);
}
//call validate id
if(VerifyID(idNumber))
{
goto Start;
}
//LCD.fillScreen(ST77XX_BLACK);
//LCD.println("Enter user ID number and press '#'");
}
// char customKey = customKeypad.getKey();
// if (customKey != '\0' )
// {
// LCD.fillScreen(ST77XX_BLACK);
// LCD.setTextColor(ST77XX_WHITE);
// LCD.setTextSize(5);
// LCD.setCursor(0, 0);
// LCD.println(customKey);
// Clear customKey
// customKey = '\0';
//Serial.println(customKey);
//}
delay(50);
}
bool VerifyID(string id)
{
return true;
}
bool VerifyPostCode()
{
return true;
}
void StoreVote()
{
}
Loading
esp32-devkit-c-v4
esp32-devkit-c-v4
keypad1:R1
keypad1:R2
keypad1:R3
keypad1:R4
keypad1:C1
keypad1:C2
keypad1:C3
keypad1:C4
lcd1:VCC
lcd1:GND
lcd1:CS
lcd1:RST
lcd1:D/C
lcd1:MOSI
lcd1:SCK
lcd1:LED
lcd1:MISO
btn1:1.l
btn1:2.l
btn1:1.r
btn1:2.r
btn2:1.l
btn2:2.l
btn2:1.r
btn2:2.r
btn3:1.l
btn3:2.l
btn3:1.r
btn3:2.r
btn4:1.l
btn4:2.l
btn4:1.r
btn4:2.r
btn9:1.l
btn9:2.l
btn9:1.r
btn9:2.r
btn5:1.l
btn5:2.l
btn5:1.r
btn5:2.r