Liquid Crystal Display Arduino tutorial

In this tutorial I will demonstrate the use a 1602 Liquid Crystal Display (LCD) with Arduino. This will involve four simple steps. You can find the pins configuration of the 1602 LCD by following the tutorial on the Introduction to 1602 Liquid Crystal Display. 1). What you will need  Male to male jumper wires  1602 LCD compatible with Hitachi HD44780 driver  Arduino board R3 Breadboard  10K ohm potentiometer  220 ohm resistor  Arduino USB cable  2).  Connecting the Liquid Crystal Display with Arduino        VSS pin of the LCD to ground        VCC pin of the LCD to 5V        RS pin of the LCD to digital pin 7 of the Arduino        R/W pin of the LCD to ground        E pin of the LCD to  digital pin 6 of the Arduino        D4 pin of the LCD to  digital pin 5 of the Arduino        D5 pin of the LCD to  digital pin 4 of the Arduino        D6 pin of the LCD to  digital pin 3 of the Arduino        D7 pin of the LCD to  digital pin 2 of the Arduino     For  220 ohm resistor         one end to A pin of the LCD and the other end to 5V     For  10k ohm potentiometer         Slider pin of the potentiometer to LCD VO pin of the LCD          A and B pins of the potentiometer to +5V and ground respectively 3).  Type in the code Open up your Arduino IDE and type in the code below. The sketch uses a nested for loop (loop within a loop) to calculate the product of two real numbers x and y and then displays the result z which is also a real number.  //Include the LCD library #include <LiquidCrystal.h> //Initialize the LCD arduino pins LiquidCrystal lcd(7,6,5,4,3,2); void setup() { //LCD number of columns and rows: lcd.begin(16, 2); } void loop() { int x, y, z; //where we will have x*y = z for(x=1; x<=9; x++) //Outer loop { lcd.clear(); //Clear the contents on the screen lcd.setCursor(3,0); // set the cursor to column 3, line 0 lcd.print(“TABLE NINE”); for(y=1; y<=9; y++) //Inner loop { z=x*y; lcd.setCursor(3,1); // column 3, line 1 lcd.print(x); lcd.setCursor(5,1); // column 5, line 1 lcd.print(“x”); lcd.setCursor(7,1); // column 7, line 1 lcd.print(y); lcd.setCursor(9,1); // column 9, line 1 lcd.print(“=”); lcd.setCursor(11,1); // column 11, line 1 lcd.print(z); delay(1000); // delay for 1 second } } } 4).  Power up and upload the sketch (code) Power up your Arduino from your pc using usb cable and then upload the sketch onto your board. Refer to the below video.

Liquid Crystal Display Arduino tutorial Read More »

Introduction to 1602 Liquid Crystal Display (16×2 LCD)

A 1602 liquid crystal display (LCD) module consists of 16 columns and two rows. This means that the LCD can display 16 characters per line (16 Characters x 2 Line). The LCD has found a wide range of applications because of its cheap price and the ease to program. The LCD can display the alphabet and number characters making it an alphanumerical display module. Each character is built on a 5×8 pixels dots. It is also possible to display special and custom generated characters on this type of display. See the datasheet.   Pinouts and Pin description of a 1602 liquid crystal display module The VSS and the VDD pins are used to power the LCD and are connected to the ground and +5 volts respectively. VO pin is for adjusting the contrast of the LCD and is normally connected to a potentiometer (variable resistor). RS pin is the Register Select pin. This will select data register when high, and command register when low. Read/Write (R/W) pin is used to toggle the LCD between the read from and write to the register operations. When set low, R/W pin will write to the register. While on the other hand, when set high, it will read from the register. This pin is normally grounded for the data writing operations to the LCD as in our example below. Enable (E) pin is the data read/write operations enable signal. Pins D0 – D7 are for data transfer. D0 – D3 is restricted to 8-bit data. For our case, we will be using pins D4 – D7 for both the 4 bits and 8 bits data transfer. BLA and BLK are for powering the LCD backlight with +5volts and ground respectively. The 1602 LCD can be connected directly to the micro-controller boards such as the Arduino. The other alternative is to use the I2C module. The module will help minimize the number of pins to be taken from the micro-controller while interfacing it with the LCD (LCD I2C).  

Introduction to 1602 Liquid Crystal Display (16×2 LCD) Read More »

Getting Started with the Arduino (IDE)

In the previous section (Introduction to Arduino) we learnt about Arduino. In this section we are going to download and install the Arduino IDE. We will then use the example code in the IDE to blink the Arduino Built-in LED. Consider following the below steps;   Download the Arduino IDE Download the latest version of the Arduino IDE from the Arduino website. Once the download has finished, double click to install. The installation process is self-guiding. You only need to follow the steps.   Agree to the license terms by clicking the agree button.  The next window is about the optional features you would like to install along with the Arduino software. If you prefer the program to automatically create the desktop shortcut be sure to select the option. It is good to ensure that all the options are selected. Click next The next window allows you to choose the installation directory. I recommend that you leave the default directory and just click install. The installation process will start and it will take some minutes to finish. Once the installation is complete you will be prompted to close the setup. Just click the close button. Launch the Arduino IDE program from the desktop shortcut. The following window will appear. This is the Arduino IDE where you write your programs to feed into the Arduino. The IDE is very simple and easy to use. Connect the Arduino Firstly, get your Arduino board and lay it on the table. Take the USB cable and plug the B plug end into the USB jack on the Arduino. Next, connect the other end of the USB cable into the USB socket on your PC. You will see the power LED (usually green) on the board light up to show that you have powered the board. You will now have to select the appropriate Arduino board from the Tools > Board > Arduino Uno. You will be provided by the list of the Arduino boards. Be sure to select the appropriate board. For my case I will select the Uno board because it’s the one I am using. Select the communication port for your Arduino from the Tools > Port > COM21(Arduino Uno). We are now going to blink the inbuilt LED on the Arduino board. This LED is connected to the digital 13 of the Arduino board. You can access the example code by going to File > Examples > Basics>Blink. To upload the code you will click the upload button on the Arduino IDE. This upload button is represented by the right facing arrow below the menu bar. Clicking this button will upload the code into the Arduino board. If there is no error in your coding and connection, you will see the done uploading message on the lower left corner of the Arduino IDE as shown below.  The on-board LED labelled L will blink in an interval of 1 seconds. Congratulation!!! You have just successfully uploaded your first Arduino program.

Getting Started with the Arduino (IDE) Read More »

Introduction to the Arduino and Arduino Boards

What is an Arduino An Arduino is an Open Source small computer that you can program to process its input and output pins. It was originally designed for students without a background in electronics and programming. Through the use of hardware and software, one can use the Arduino to interact with the environment. The simplest example is to use the Arduino to blink an LED connected to one of its output pins. The Arduino board is made of a microcontroller which forms the heart of the board.  It also has a crystal oscillator which basically acts as a clock that sends time pulses to the microcontroller to enable it to operate at the correct speed. The board also has digital and analog Input and Output pins to enable one to connect the microcontroller pins to other components such as LEDs, sensors, shields and modules. The Arduino Integrated Development Environment (IDE) is used to write a computer program that you can then upload to the Arduino. Once the code is uploaded to the Arduino, it will carry out the instructions in the code and enables the Arduino interact with the outside world.   Types of Arduino Boards There are many kinds of Arduino boards but the most common ones are; Uno Mega Leonardo Nano Due The Arduino Uno board offers the best option for the beginners in the Arduino world. It consists of 14-digital pins and 6-analog pins. The digital pins can be used as both the input/output (I/O) pins to the Arduino while the analog pins as input pins. You now know what an Arduino is and what it can do. In the next topic we will get started with the Arduino. This will involve downloading and setting up the Arduino IDE for uploading the codes (Arduino Sketches). We will then use the Arduino in a number of projects. You can download the Arduino IDE here.

Introduction to the Arduino and Arduino Boards Read More »

Shopping Cart
Scroll to Top