This is an old revision of the document!
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 an LCD Displaytech 162B based on the HD44780 standard. It is necessary to initialize the library by associating any pin of the LCD interface necessary to the Arduino pin number to which it is connected (see Step 2).
The circuit: LCD pin 1 = 5v+ (220 ohm resistance) LCD pin 2 = GND LCD pin 3 = GND LCD pin 4 = 5v LCD pin 5 = center of potentiometer (potentiometer leg 1 goes to 5v and leg 3 goes to ground) LCD pin 6 = Arduino pin 7 LCD pin 7 = GND LCD pin 8 = Arduino pin 6 LCD pin 13 = Arduino pin 5 LCD pin 14 = Arduino pin 4 LCD pin 15 = Arduino pin 13 LCD pin 16 = Arduino pin 2
Scenario 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. To note, delays are provided as ms (milliseconds) in terms of unit of measure, not as s (seconds). Result You should see the text “Smart lab!” appearing and disappearing every half second. Start There are no special steps to be performed.
Steps Step 1 Include LCD driver library: #include <LiquidCrystal.h> Step 2 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); Step 3 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!");
}
Step 4 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);
}
Result validation Observe the text appearing and disappearing every half second.
Platformio.ini
[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
B1.cpp
#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);
}