Introduction
This post it is showed how to connect an LCD screen to an Arduino based PLC. This post, it is used an LCD 2004A model and an Ardbox PLC family. This example will work with any PLC from the 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 do connect these devices?
Next, it is shown an electric diagram of how to connect Arduino based PLC and LCD screens:
As you can see is required to use I2C and SPI pins, so you can not use these communications using an LCD screen without any driver. Normally is recommended to use an LCD screen with an I2C driver. Unfortunately using these pins it’s not possible to use some I/Os of the PLC. Take a look at how to configure the switches to know which I/Os is disabled. Â
Once the devices are set juts it 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 call on your sketch. See more information about this library HERE. The 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:
How to connect an LCD screen to an Arduino based PLC