Step 1: RFID + LCD interface

RFID Kit Step 1: wiring up the LCD

Below is the wiring diagram for connecting up a LCD screen, a buzzer and a button.

Connecting of the LCD screen is the same the LadyAda Wiring up a character LCD to an Arduino.  So I will not cover the ins and outs of that and just deal with the custom characters, buzzer and the button.

We use custom characters to display a countdown bar, each character is made up of 7 rows and 5 columns.  Below is a representation of the custom characters used from full to blank.

LCD screen display for count down


A line of 16 full custom characters are printed to the LCD, then one by one the last character on the display is replaced with the next custom character until it becomes blank and it moves onto reducing the next screen character position.

As each segment is removed Pin 13 is changed from HIGH to LOW or LOW to HIGH causing the speaker to beep.

On the wiring diagram you can see I used a 200Ω resistor connected to the speaker so it’s not too alarming.

To start the LCD count down you just put the button.  This button is wired up with a hardware debounce,

which consists of a 10kΩ resistor and a 100nF ceramic capacitor.

Hint: if the count down starts right away without the button pressed, double check the wiring of the button for all connections.

Wiring details

Click to see larger Image



//  LCD count down with button and beeper.

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

byte ch0[8]={B11111,B11111,B11111,B11111,B11111,B11111,B11111,0};
byte ch1[8]={B11110,B11110,B11110,B11110,B11110,B11110,B11110,0};
byte ch2[8]={B11100,B11100,B11100,B11100,B11100,B11100,B11100,0};
byte ch3[8]={B11000,B11000,B11000,B11000,B11000,B11000,B11000,0};
byte ch4[8]={B10000,B10000,B10000,B10000,B10000,B10000,B10000,0};
byte ch5[8]={B00000,B00000,B00000,B00000,B00000,B00000,B00000,0};
int beeper = 0;                          // Beeper flag. 0 = off

void setup()
pinMode(13, OUTPUT);            // Door beeper
pinMode(A5, INPUT);                // Button input

 lcd.begin(16, 2);                       // Set up the LCD's number of columns and rows: 
print("LCD Button test");     // Print startup message to the LCD.

 Serial.begin(19200);                // Serial debugging 19200 baud, the speed the RFID card communicates at.                                            

 Serial.println("Serial Ready");
createChar(0, ch0);             // initialise our custom characters
createChar(1, ch1);
createChar(2, ch2);
createChar(3, ch3);
createChar(4, ch4);
createChar(5, ch5);
// end setup

void loop()
boolean buttonState = digitalRead(A5); // get button state
 buttonState =! buttonState;                 
// Invert button state to match logic
if (buttonState == true){
setCursor(0, 1);
for (int i=0; i <= 15; i++)  // print 16 block characters
print((char) 0);
for (int i=15; i >= 0; i--)  

    {                                    // loop through the 16 characters in row
for (int c=0; c <= 5; c++)  

      {                       // loop through the 5 places that make up a character
digitalWrite(13, beeper);// Turn beeper on or off
setCursor(i, 1);
print((char) c);         // print our custom character
delay(100);                  // the delays add up to about 8 seconds, 
// that's how long the door lock will be open for.
digitalWrite(13, 0);         // set beeper off
// end if button loop
// end mail loop 

Next Step: motorised lock control

Zircon - This is a contributing Drupal Theme