Internet of Things – Actuators

Today I will show you how to control an LCD display as an actuator for an Internet Thing. I will do it by connecting to a news feed to continuously show the top news on the display.

As you may have seen in some of my previous videos, it’s possible to use a microcontroller, like an Arduino, to act as an indicator of what is happening somewhere on the Internet. When this happens, we are making use of actuators. They can be thought of as digital fingers, which can manipulate the environment in different ways. There are many different actuators, and some examples include relays, motors, LEDs, and different kind of displays.

Here you can see the needed hardware for this lab, and in addition to the Arduino, the important components are the LCD display and a potentiometer to control the contrast. To connect everything, you need a breadboard, a 220 ohm resistor, and fifteen jumper cables that have a (male) pin on each end.

To setup the hardware, you start by disconnecting everything from its power source, and then connect the 5V and GND on the Arduino to the breadboard. Connect 5V to one of the sides of the potentiometer, and to the LCD’s pin 2 and over the resistor to its pin 15. Connect GND to the other side of the potentiometer and to the LCD’s pins 1, 5, and 16. Then connect the center of the potentiometer to pin 3 on the LCD, and finally the Arduino connect to the LCD with pins 2 to 11, 3 to 12, 4 to 13, 5 to 14, 11 to 4, and 12 to 6.

To make things easier for the Arduino, I will set up an omnichannel service. Here is the code…

…and first it gets the latest top news from FeedZilla (on line 2). Then it parses the JSON returned (on line 3), and return the title (on line 4). This service can be deployed to a cloud server, with the name news.php, and I showed how to do that in my previous video named “Omnichannel Services – First Service”.

Here is the Arduino code (sketch)…

…and after the initial includes, the LCD screen object is created with the pins specified (on line 4), followed by some variable declarations (on lines 5-6). In the setup, we define the LCD display size (on line 10), and initialize the bridge (on line 11), which allows communication between the microcontroller and the microprocessor. The eternal loop starts by getting the content from the omnichannel service (on lines 16-22, and make sure to replace 0.0.0.0 with the IP address of your server), and the first and second lines are extracted (on lines 23-24). The LCD is cleared (on line 25), and the two lines are printed on the LCD (on lines 26-28), and then there is a delay for 10 seconds (on line 29) until the loop starts over again.

That is how an actuator like an LCD display can be used to show information from anywhere on the Internet.