Data Sheet

75 : circuit 4a
CODE TO NOTE
LCD LIBRARY:
#include <LiquidCrystal.h>
Includes the LiquidCrystal library in your
program.
LCD LIBRARY INSTANCE:
LiquidCrystal LCD_name(RS_pin,
enable_pin, d4, d5, d6, d7);
As with servos, you need to create an LCD
object and give it a name (you can make
more than one). The numbers in the brackets
are pins on the RedBoard that connect to
specific pins on the LCD.
LCD BEGIN:
lcd.begin(16, 2);
This line initializes the LCD object and tells
the program the LCD’s dimensions. In this
case it is 2 rows of 16 characters each.
LCD CLEAR:
lcd.clear();
This method clears all the pixels on the
display.
LCD CURSOR:
lcd.setCursor(0,0);
Moves the cursor to a point on the 16x2 grid
of characters. Text that you write to the LCD
will start from the cursor. This line is starting
back at position (0,0).
LCD PRINT:
lcd.print(“Hello, world!”);
Prints a string of characters to the LCD
starting at the cursor position.
CODING CHALLENGES
CHANGE THE MESSAGE: Try changing the code to display another message.
SHOW HOURS, MINUTES AND SECONDS: Try adding some code so that the
display shows the hours, minutes and seconds that have passed since the RedBoard
was last reset.
COUNT BUTTON PRESSES: By adding a button to the circuit, you can count the
number of times the button was pressed or have the button change what displays.