Arduino + LCD MD216-01 Rev.A

I was back at my home for a week and I decided to bring back a few things… Among them there is an Arduino Duemilanove, some breadboards and an LCD display (MD216-01 Rev.A 16 characters 2 lines). All bougth long back at BricoGeek.

UntitledSo I decided it is a good idea to build a small project. I’m going to build a start/stop timer.

But before, do you remember my other posts about Arduino?

Father and Daugther

Raspberry Pi 001: Setup and Run first Arduino-Python project.

Hope you like them. Now for the timer. This is my list of components:

  • Arduino Duemilanove
  • LCD (taken from old equipment)
  • Button (taken from old equipment)
  • LED (taken from old equipment)
  • 2x Variable resistor (taken from old equipment)
  • Breadboard
  • Connectors
  • Piezo speaker (taken from a Christmas card)


I couldn’t find any more the spreadsheet for my particular LCD, but I found a good tutorial here (The only difference is in the pins for the back-light).

1. Because I want to be able to use the Arduino and don’t destroy this project, the first step is to build a buffer in the breadboard. We connect Gnd and 5V from the Arduino to the breadboard, and Arduino digital pins from 5 to 7 to the corresponding pins in the breadboard. In this way we can remove the Arduino and know exactly which pins we need to connect again.


2. Connect LCD in the left hand side as shown. Pins will go from 1 to 16 in this model.


To understand what pins do, we have this nice video.

3. Connect pins!

LCD  –> Arduino

1 — Gnd

2 — +5V

3 — Middle pot of a variable resistor between +5V and Gnd

4 — 7

5 — Gnd

6 — 8

11 — 9

12 — 10

13 — 11

14 — 12

15 — Gnd

16 — Middle pot of a variable resistor between +5V and Gnd

The variable resistors will control the back ligth and the contrast. Once it is set you can read their value and replace them with standard resistors.

Now connect the piezo to Gnd and Pin 6 of the Arduino. Connect the LED to Gnd and Pin 5.

For the button, connect one side to Gnd  and the other side will be connected to a resistor that goes to +5V and a capacitor that goes to Pin 4. The final result is something as messy as this:


4. Now your LCD screen is connected to the Arduino, time to check it. To do that load an example File>Examples>LiquidCrystal>HelloWorld

Before running this example you need to define which are the pins. In our case it has to be:

LiquidCrystal lcd(7,8,9,10,11,12);

Now you can compile and upload the code:


5. Let’s now modify this to show a proper clock counter and make Arduino to read the button to reset the counter. We start with the code for the HelloWorld and tweak it a little bit:


#include "pitches.h" //For playing a note with the piezo
#include <LiquidCrystal.h> //Libraries for the LCD

LiquidCrystal lcd(7,8,9,10,11,12);  //Defiying the pins in the LCD

int notes[] = {
  NOTE_A4, NOTE_B4,NOTE_C3 }; //3 notes

const int buttonPin = 4;     // the number of the pushbutton pin
const int ledPin =  5;      // the number of the LED pin
const int piezoPin =  6;      // the number of the piezo pin

int buttonState = 0;         // variable for reading the pushbutton status
int counter = 0;
int hours = 0;
int minutes = 0;
int seconds = 0;

void setup() {
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);      
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);    
  // initialize the piezo pin as an output:
  pinMode(piezoPin, OUTPUT); 
  // Writte in the LCD symbols that will not change
  lcd.setCursor(2, 1);  
  lcd.setCursor(5, 1);  
  lcd.setCursor(8, 1);

void loop(){  
  //Now while the button is unpressed the counter will tick
  while (digitalRead(buttonPin)== HIGH){
    digitalWrite(ledPin, HIGH);  
    delay(100); //wait for 100 ms
    counter = counter +100;
    //This is for setting the counters into the next multiple
    if (counter>= 1000){
    if (seconds>= 60){
    if (minutes>= 60){
    //Now this code is for writting the time
    //We want to have zeros before numbers
      lcd.setCursor(0, 1);
      lcd.setCursor(0, 1);
      lcd.setCursor(1, 1);
    // print the number of hours since reset:
      lcd.setCursor(3, 1);
      lcd.setCursor(3, 1);
      lcd.setCursor(4, 1);
    // print the number of minutes since reset:
      lcd.setCursor(6, 1);
      lcd.setCursor(6, 1);
      lcd.setCursor(7, 1);
    // print the number of seconds since reset:
      lcd.setCursor(9, 1);
      lcd.setCursor(9, 1);
      lcd.setCursor(10, 1);
    // print the number of seconds since reset:
  //When we press the button the LED will be off and the counter reset
  // turn LED off:
  digitalWrite(ledPin, LOW); 
  tone(piezoPin, notes[1],20);
  counter =0;
  seconds =0;


NOTE: Sometimes the command

 #include "pitches.h"

doesn’t work properly and you need to load and compile the example File>Examples>Digital>toneMelody


and voilà!!!!


Hope you like it.












Ok ok, one extra, look at this SNES-like controller they sell, isn’t it awesome?




One thought on “Arduino + LCD MD216-01 Rev.A”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s