Browse our Blog. You will find multiple applications, solutions, code examples. Navigate using the tag cloud or search using specific criteria

How to connect an LCD screen to an Arduino based PLC

Introduction

On this post it is showed how to connect a LCD screen to an Arduino based PLC. On this post it is used an LCD 2004A model and an Ardbox PLC family. This example will work with any PLC from M-Duino family.


Requirements


Ethernet or 20 I/Os PLC:    Ethernet PLC             20 I/Os PLC    

Industrial Shields boards:  How to use the mapping pins of Industrial Shields boards       

 

20kohms potentiometer and 220 ohms resistor.


Description

How to connect these devices?

Next it is showed an electric diagram of how to connect Arduino based PLC and LCD screen:


As you can see is required to use I2C and SPI pins, so you can not use these communications using a LCD screen without any driver. Normally is recommended to use LCD screen with a I2C driver. Unfortunately using these pins it’s not possible to use some I/Os of the PLC. Take a look on how to configure the switches to know which I/Os are disable.  

Once the devices are set juts is requires the software to make it run properly. For this post it is used a very useful Arduino library called LiquidCrystal. LiquidCrystal allows an Arduino board or Arduino based PLC to control LCD’s based on Hitachi HD44780 or compatible chip-set. The library works for 4- or 8-bit mode. On this post, as you can see on the wiring, it is installed just with 4-bit mode.

How to install the software?

LiquidCrystal is included by default when you install Arduino IDE. So you just have to called on your sketch. See more information of this library HEREThe lines below is showed a simple example of how to use LiquidCrystal library:

#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to

const int rs = 2, en = 3, d4 = 7, d5 = 16, d6 = 14, d7 = 15;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
  // set up the LCD's number of columns and rows:
  
  lcd.begin(20, 4);
  
  // Print a message to the LCD.
  
  lcd.print("Screeno by IS");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  
  lcd.setCursor(0, 1);
  
  // print the number of seconds since reset:
  
  lcd.print(millis() / 1000);
  lcd.setCursor(3, 1);
  lcd.print("s");
}

 

Next it’s showed how LCD looks:

Do you want more information?

Open Source technology allows you to develop your installations.

Just fill the form and we will contact you as soon as we can.

Send