In this new lesson on Arduino we will see how to use the KeyPad to enter a code , which will be verified through a connection to a MySQL DB .

We have already seen in lesson 8 , how to use the KeyPad (both 4 × 3 to 4 × 4 ) with Arduino , to read and verify code which is input from this device . However you have not exploited the potential that the Internet offers ; In fact the verification code was entered directly into the Arduino code and therefore any changes to the code , requiring a direct intervention in micro - controller . With this small project , you can load all the 6-digit codes that you want in our MySQL DB and Arduino will check if the code is correct . Simple right ?

Step 1: Software

Hardware Requirements

  • Arduino Uno / Arduino Mega
  • Ethernet Shield KeyPad 4 × 4
  • A PC / Raspberry / DB

Software Requirements

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 :


The software works better with Arduino Mega than with Arduino Uno due to memory space problems.

About This Instructable




Bio: I'm an Arduino Maker, I like technology, playing tennis
More by jackbell16:How to let comunicate Arduino with KeyPad to DB MySQL. Arduino water system to wet your plant How to make an alarm system with Arduino 
Add instructable to: