If you have one of these screens this demo sketch lets you see the whole character set. Our sketch will use the wiring connections you see in the DFRobot Shield and many clone display boards.
Open New SketchEnter this code. Compile to make sure everything is okay.
#include <LiquidCrystal.h>
// DFRobot shield Uno connections Enable 8, RS 9, data 4, 5, 6, 7
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
const int numRows = 2; const int numCols = 16;
void setup(){ lcd.begin(numCols, numRows); }
void loop() {
for (byte thisLetter = '!'; thisLetter <= '~'; thisLetter++) {
// loop over the columns:
for (int thisRow = 0; thisRow < numRows; thisRow++) {
// loop over the rows:
for (int thisCol = 0; thisCol < numCols; thisCol++) {
// set the cursor position:
lcd.setCursor(thisCol, thisRow);
// print the letter then increment
lcd.write(thisLetter++);
delay(500); }}}}
The line with LiquidCrystal lcd(8, 9, 4, 5, 6, 7); is called a constructor. The numbers are digital IO pin numbers from your board. Wires connect the pins to an electronic display screen.
This project works with a DFRobot Display shield because it uses the correct pin numbers. If the sketch does not work the display then pin wiring or contrast setting are possibilities.
The CodeASCII is a computer alphabet that has been around for decades. It contains about 100 alphanumeric characters: numbers, capital letters and small ones. Our sketch uses functions like lcd.begin to turn on the screen and lcd.write to print letters.
We position our cursor and write a letter from the ASCII alphabet. The sketch cycles through the code and returns to the beginning. We use an 8bit byte called thisLetter that contains a value between "'" and "~". Our compiler knows ASCII and reads these values as decimal 33 and 126.
UploadYou should see the ASCII character set scroll across the screen.
Experiment with your display screen. In the same way that it prints letters and numbers it is programmed to make many symbols.
Comments
Please log in or sign up to comment.