- Arduino Uno / Arduino Mega
- Ethernet Shield KeyPad 4 × 4
- A PC / Raspberry / DB
The mechanism of operation is as follows; the user enters the alphanumeric code through the KeyPad. Once completed enter the 6 digits, press the * key and remains pending verification. Once complete such operations, Arduino communicate through the serial if the code is correct or not and turn on the LED 13. The code can also be more in length, but must be changed in the source code. First of all you need to create a diagram in the MySQL DB. In my case I called Auth. There is only one table of name codes, which has as attributes a single element which is Code, an element of type varchar (10), which is the primary key and should not be anything. To do these tasks you can safely use the MySQL Workbench, which is a program very easy to use. For more information about MySQL, I recommend you read this article. Here is the program code for Arduino Uno / Arduino Mega that allows you to check the correctness of code added to KeyPad, relative to those in the MySQL DB.
The verification of the correctness of the code is inserted by the function isAuthorized ( char code [ ] ) ; This function checks whether the number of rows returned by the query to the database is greater than 0. The query is :
Select * From Codes Where Code = 'A47DCB'
In order to send the running the program , you must enter a username password of your MySQL DB . Then you must enter the codes that are valid . To do this you can use this query :
INSERT INTO Codes(Code) VALUES ('A47DCD')
The software works better with Arduino Mega than with Arduino Uno due to memory space problems.