Cov txheej txheem:

Arduino UNO (tsim Menus thiab Ua Haujlwm): 4 Cov Kauj Ruam
Arduino UNO (tsim Menus thiab Ua Haujlwm): 4 Cov Kauj Ruam

Video: Arduino UNO (tsim Menus thiab Ua Haujlwm): 4 Cov Kauj Ruam

Video: Arduino UNO (tsim Menus thiab Ua Haujlwm): 4 Cov Kauj Ruam
Video: Как написать меню для дисплея на Arduino 2024, Kaum ib hlis
Anonim
Arduino UNO (tsim Menus thiab Ua Haujlwm)
Arduino UNO (tsim Menus thiab Ua Haujlwm)
Arduino UNO (tsim Menus thiab Ua Haujlwm)
Arduino UNO (tsim Menus thiab Ua Haujlwm)

Hauv cov lus qhia no peb yuav tshawb nrhiav yuav tsim cov ntawv qhia zaub mov li cas, nyeem qhov ntsuas kub los ntawm TC74A0 sensor thiab tso tawm "qhov tseem ceeb" (qhov no yog xov tooj ntawm tes) hauv qhov uas tsis muaj qhov kawg, tab sis txwv rau arduino's on board memory.

Peb yuav siv

-Array

-Liquid siv lead ua zaub

-Cov keyboard

Cov neeg siv phau ntawv qhia suav nrog hauv cov kauj ruam kawg.

Kauj Ruam 1: Cheeb Tsam

Arduino Ib

· 4x4 keypad

· TC74A0 cov ntsuas kub digital

· I2c 16x2 LCD Module

· 16x2 kua siv lead ua kua

· Jumper xov hlau

· Daim ntawv qhia zaub mov

· Tus kheej lub computer

· Arduino IDE

· Hloov kab

Kauj Ruam 2: Kev Txuas Hluav Taws Xob

TEMP SENSOR THIAB LCD txuas ntawm tib txoj kab rau SDA THIAB SCL (A4, A5)

LCD (I2c Module)

o SDA rau A5 ntawm Arduino

o SCL rau A4 ntawm Arduino

o VCC rau 5V ntawm Arduino

o GND rau GND ntawm Arduino

4 x 4 Keypad

o Pin 1 - 8 ntawm Keypad txuas nrog tus pin 9 - 2 ntawm Arduino feem

TC74A0 kub sensor

o TC74A0 tus pin 2 rau SDA ntawm Arduino

o TC74A0 tus pin 3 rau GND ntawm Arduino

o TC74A0 tus pin 4 rau SCL ntawm Arduino

o TC74A0 tus pin 5 txog 5V ntawm Arduino

Kauj ruam 3: Code

#suav nrog // suav nrog cov tsev qiv ntawv thaum sau ua ke

#suav nrog

#suav nrog

#define Password_Lenght 5

#define Command_Lenght 3

#Txhais CellNumber 10

cov neeg siv = 0;

int Zaub = 0;

int chaw nyob = 72; // tc74a0 chaw nyob

int kuv = 0;

koj USER;

int X = 0;

int XY = 0;

koj temp;

int tempPre = 0;

char userNum [10] [10] = {{}, {}, {}};

char Cov Ntaub Ntawv [Password_Lenght];

char Master [Password_Lenght] = "5466"; // PASSWORD

char ExitData [Command_Lenght]; //

char Master1 [Command_Lenght] = "**"; //

char Ntawv qhia zaub mov;

char CELLArrayA [10];

char CELLArrayB [10];

char CELLArrayC [10];

const byte ROWS = 4; // plaub kab

const byte COLS = 4; // plaub kab

byte rowPins [ROWS] = {5, 4, 3, 2};

byte colPins [COLS] = {9, 8, 7, 6};

byte data_count = 0, master_count = 0;

bool Pass_is_good;

LiquidCrystal_I2C lcd (0x26, 16, 2);

char hexaKeys [ROWS] [COLS] = // INITIATING KEYPAD

{

{'1', '2', '3', 'A'}, {'4', '5', '6', 'B'}, {'7', '8', '9', 'C'}, {'*', '0', '#', 'D'}

};

Keypad customKeypad = Keypad (uaKeymap (hexaKeys), rowPins, colPins, ROWS, COLS);

void teeb tsa ()

{

Serial.begin (9600); // qhov no tsim Serial Monitor

Hlau.begin (); // qhov no tsim cov khoom Hlau

lcd.begin (16, 2);

lcd.backlight ();

lcd.clear ();

lcd.setCursor (0, 0);

lcd.print ("Thov Tos 3"); LOADING SCREEN

ncua (1000);

lcd.clear ();

lcd.setCursor (0, 0);

lcd.print ("Thov Tos 2");

ncua (1000);

lcd.clear ();

lcd.setCursor (0, 0);

lcd.print ("Thov Tos 1");

ncua (300);

lcd.clear ();

Txoj hlua myString = "ARDUINO INSTRUCTABLE";

lcd.setCursor (2, 2);

lcd.print (myString);

ncua (2500);

rau (int scrollCounter = 0; scrollCounter <24; scrollCounter ++)

{

lcd.scrollDisplayLeft ();

ncua (300);

}

lcd.clear ();

lcd.print ("Nkag Nkag Password");

}

void lub voj ()

{

hloov (Zaub) // QHOV TSEEB NTAWV hauv cov ntsiab lus tseem ceeb yog peb

{// Puas yog tus neeg siv xovxwm A, B, C, D

rooj 0:

{

Lo lus zais ();

}

tawg;

rooj plaub 1:

{

lcd.clear ();

lcd.setCursor (0, 1);

lcd.print ("A B C D");

lcd.setCursor (0, 0);

lcd.print ("Ntawv qhia zaub mov tseem ceeb");

Zaub = 2;

ncua (100);

tawg;

}

rooj plaub 2:

{

char customKey = customKeypad.getKey ();

hloov (customKey)

{

cas 'A':

{

Serial.println ("A raug nias");

StoreUser ();

tawg;

}

cas 'B':

{

Serial.println ("B raug nias");

yog tias (cov neeg siv == 0) {

lcd.clear ();

lcd.print ("TSIS TXHOB SIV USERS");

ncua (3000);

lcd.clear ();

Zaub = 1;

tawg;

}

DisplayUsers (); tawg;

}

cas 'C':

{

Serial.println ("C raug nias"); // Siv sijhawm xeem ntawv

int ext = 0;

thaum (! ext) {

caj ch;

qhov = TempMenu ();

yog (temp! = tempPre) {

lcd.clear ();

lcd.print ("Temparature");

lcd.setCursor (0, 1);

lcd.print (kub);

lcd.print ("C");

tempPre = temp;

ncua (500);

}

ch = customKeypad.getKey ();

yog (ch == ' *') // QHOV TEMPERATURE MENU (yog * XOV XWM)

{

ext = 1;

lcd.clear ();

Zaub = 1;

}

}

tawg;

TempMenu ();

tawg;

}

cas 'D':

{

lcd.clear ();

lcd.setCursor (0, 0);

lcd.print ("NUA PRAC");

lcd.setCursor (0, 1);

lcd.print ("JB SCHOEMAN");

ncua (3000);

lcd.clear ();

lcd.setCursor (0, 0);

lcd.print ("YOG 2019");

lcd.setCursor (0, 1);

lcd.print ("CC OOSTHUIZEN");

ncua (3000);

lcd.clear ();

Zaub = 1;

}

}

}

}

}

// CUSTOM FUNCTIONS CALL VALUES OR PROCEDURES

tsis muaj lo lus zais ()

{

char customKey = customKeypad.getKey ();

yog (customKey) // ua kom ntseeg tau tias tus yuam sij tau raug nias, sib npaug rau (customKey! = NO_KEY)

{

Cov ntaub ntawv [data_count] = customKey; // khaws char rau hauv cov ntaub ntawv array

lcd.setCursor (data_count, 1); // txav tus cursor los qhia txhua tus cim tshiab

lcd.print ("*"); // luam kab ntawv ntawm tus cursor hais

data_count ++; // nce cov ntaub ntawv ntau ntxiv los ntawm 1 txhawm rau khaws cov char tshiab, tseem khaws cov lej ntawm tus lej nkag mus

}

yog (data_count == Password_Lenght-1) // yog tias qhov ntsuas qhov ntsuas sib npaug rau tus lej ntawm cov cim xav tau, sib piv cov ntaub ntawv rau tus tswv

{

lcd.clear ();

lcd.setCursor (0, 0);

lcd.print ("Lo lus zais yog");

yog (! strcmp (Cov Ntaub Ntawv, Tswv)) // sib npaug rau (strcmp (Cov Ntaub Ntawv, Tswv) == 0)

{

lcd.print ("Zoo");

lcd.clear ();

Zaub = 1;

}

lwm tus

lcd.print ("Phem");

ncua (1000); // ntxiv 1 lub sijhawm ncua thib ob kom paub tseeb tias tus lej zais tau qhia meej ntawm lub vijtsam ua ntej nws yuav raug tshem tawm.

lcd.clear ();

clearData (); cov

lcd.clear ();

lcd.setCursor (0, 0);

lcd.print ("Nkag Nkag Password");

}

}

koj TempMenu ()

{

Wire.beginTransmission (chaw nyob);

Hlau.write (0);

Wire.endTransmission ();

Wire.requestFrom (chaw nyob, 1);

thaum (Wire.available () == 0);

int c = Hlau.read ();

rov c;

}

tsis muaj dab tsi clearData ()

{

thaum (data_count! = 0)

{// Qhov no tuaj yeem siv rau txhua qhov loj me, Cov ntaub ntawv [data_count--] = 0; // ntshiab array rau cov ntaub ntawv tshiab

}

}

void StoreUser ()

{

int ext = 0;

tus neeg siv;

caj ch;

thaum (! ext) {

lcd.clear ();

lcd.print ("Sau Tus Neeg Siv");

neeg siv = neeg siv + 1;

lcd.print (neeg siv);

int x = 0;

thaum (! x) {

rau (int kuv = 0; kuv <10; kuv ++) {

ch = customKeypad.waitForKey ();

lcd.setCursor (kuv, 1);

lcd.print (ch);

userNum [neeg siv - 1] = ch;

}

ncua (500);

lcd.clear ();

lcd.print ("Mus Ntxiv");

lcd.setCursor (0, 1);

lcd.print ("* yog # tsis yog");

ch = customKeypad.waitForKey ();

yog tias (ch == '*') {

x = 1;

}

yog (ch == '#') {

x = 1;

ext = 1;

lcd.clear ();

Zaub = 1;

}

}

cov neeg siv ++;

}

}

void DisplayUsers ()

{

lcd.clear ();

rau (int kuv = 0; kuv <cov neeg siv; kuv ++) {

lcd.print ("Tus Neeg Siv Tau Txais");

lcd.print (kuv + 1);

rau (int u = 0; u <10; u ++) {

lcd.setCursor (u, 1);

lcd.print (userNum [kuv] [u]);

}

ncua (2000);

lcd.clear ();

Zaub = 1;

}

}

Kauj Ruam 4: TUS NEEG UA HAUJ LWM

1. Thaum hloov pauv ntawm qhov haujlwm, qhov chaw thau khoom lossis tos txais yuav tshwm sim.

2. Lub vijtsam “Enter Password” yuav tshwm sim, lub vijtsam no tso cai rau koj nkag mus 4 tus cim, ntawv lossis lej, tus lej raug yog: 5466, qhov no yuav tso cai rau koj nkag mus rau cov ntawv qhia zaub mov tseem ceeb.

3. Thaum nkag mus rau tus lej nkag mus raug, cov ntawv qhia zaub mov tseem ceeb yuav tshwm sim nrog 4 txoj hauv kev xaiv mus rau qhov ua haujlwm sib txawv.

· A - Sau tus neeg siv tus lej xov tooj.

o Sau 10 tus lej txhawm rau txuag tus neeg siv rau hauv kab ke

o Tom qab 10 tus lej tau nkag mus nias " *" txhawm rau ntxiv cov neeg siv, lossis nias "#" kom rov qab mus rau lub tshuab raj tseem ceeb

· B - Zaub txuag cov neeg siv

o Cov neeg siv yuav hla dhau lub vijtsam, lawv tau tshwm rau 3 vib nas this txhua, sai li sai tau txhua tus neeg siv tau tso tawm nplooj ntawv yuav kaw thiab rov qab mus rau cov ntawv qhia zaub mov tseem ceeb.

o Yog tias tsis muaj cov neeg siv tau ntxiv rau hauv cov ntawv xaiv A, nws yuav tso tawm "TSIS SAVED USERS".

· C - Qhia qhov ntsuas kub nyob

o Nias " *" kom rov qab mus rau lub tshuab raj tseem ceeb

· D - Zaub cov ntawv luv

o Qhia tus tsim lub npe thiab cov ncauj lus nws tau suav ua ke nrog rau hnub tim.

Pom zoo: