Whatever you do, you expect to have some output of the system. Sometimes there is a blinking LED, sometimes information about connected/disconnected network and some other time simply trace algorithm progress. In laboratories where you have connected the MCU physically to your programming device (i.e., your laptop), you usually would like to choose the serial port to report about what is going on. However, here all you have at runtime is the access to the video stream. Perhaps those are the reasons why you will use the LCD display in every lab work you will do.
This hands-on lab guide is intended for the Beginners but other target groups may benefit from it, treating it as basics for advanced projects.
There are no other prerequisites besides the Liquid Crystal library. All the nodes of SmartME Network Laboratory are equipped with a 2×16 LCD Displaytech 162B based on the HD44780 standard. It is necessary to initialize the library by associating any pin of the LCD interface to the Arduino pin number to which it is connected (see Step 2).
Initialize the LCD screen with the text “SmartMe Lab!”, then turn it off, then turn it on again, in a loop: each phase lasting half a second. Delays are expressed in ms (milliseconds) and not in s (seconds).
You should see the text “Smart lab!” appearing and disappearing every half second.
There are no special steps to be performed.
Include LCD driver library:
#include <LiquidCrystal.h>
Instantiate the software controller component for the LCD display:
// initialize the library with the numbers of the interface pins LiquidCrystal lcd(7, 6, 5, 4, 13, 2);
Initialize display - we suggest to do it in the setup() function:
void setup() { // set up the LCD's number of columns and rows lcd.begin(16, 2); // print a message to the LCD lcd.print("SmartMe lab!"); }
Implement loop() to turn off and on the LCD display, for 500 ms each:
void loop() { // turn off the display lcd.noDisplay(); delay(500); // turn on the display lcd.display(); delay(500); }
Observe the text appearing and disappearing every half second.
[env:uno] platform = atmelavr board = uno framework = arduino lib_ldf_mode=deep+ lib_compat_mode=strict lib_deps_external = https://github.com/arduino-libraries/LiquidCrystal.git#1.0.7
#include <LiquidCrystal.h> // initialize the library with the numbers of the interface pins LiquidCrystal lcd(7, 6, 5, 4, 13, 2); void setup() { // set up the LCD's number of columns and rows lcd.begin(16, 2); // print a message to the LCD lcd.print("SmartMe Lab!"); } void loop() { // turn off the display lcd.noDisplay(); delay(500); // turn on the display lcd.display(); delay(500); }