SunFounder uno-and-mega-kit
LiquidCrystal is a built-in library in the Arduino IDE. You can find the LiquidCrystal folder under the installation path
C:\Program Files\Arduino\libraries
.
There is an example in the
examples
folder. The src folder contains the major part of the library:
LiquidCrystal.cpp
(execution file, with function implementation, variable definition, etc.) and LiquidCrystal.h (header file, including
function statement, Macro definition, struct definition, etc.). If you want to explore how a function is implemented,
you can look up in the file
LiquidCrystal.cpp
.
Displayed characters
char
array1[]
=
" SunFounder "
;
//the string to print on the LCD
char
array2[]
=
"hello, world! "
;
//the string to print on the LCD
These are two character type arrays:
arry1[]
and
array2[]
. The contents in the quotation marks ”xxx” are their
elements, including 26 characters in total (spaces counted).
array1[0]
stands for the first element in the array, which
is a space, and
array1[2]
means the second element
S
and so on. So
array1[25]
is the last element (here it’s also a
space).
Define the pins of LCD1602
LiquidCrystal lcd
(
4
,
6
,
10
,
11
,
12
,
13
);
Define a variable
lcd
of LiquidCrystal type. Here use
lcd
to represent
LiquidCrystal
in the following code.
The basic format of the
LiquidCrysral()
function is: LiquidCrystal (rs, enable, d4, d5, d6, d7). You can check the
LiquidCrystal.cpp
file for details.
So this line defines that pin RS is connected to pin 4, the enable pin to pin 6, and d4-d7 to pin10-13 respectively.
Initialize the LCD
lcd.
begin
(
16
,
2
);
// set up the LCD's number of columns and rows: begin(col,row) is
˓
→
to set the display of LCD. Here set as 16 x 2.
Set the cursor position of LCD
lcd.
setCursor
(
15
,
0
);
// set the cursor to column 15, line 0
setCursor(col,row)
sets the position of the cursor which is where the characters start to show. Here set it as 15col, 0
row.
LCD displays the elements inside array1[] and array2[]
for
(
int
positionCounter1
=
0
; positionCounter1
<
26
; positionCounter1
++
)
{
lcd.
scrollDisplayLeft
();
//Scrolls the contents of the display one space to the
˓
→
left.
lcd.
(array1[positionCounter1]);
// Print a message to the LCD.
delay
(tim);
//wait for 250 microseconds
}
When
positionCounter1 =0
, which accords with
positionCounter1<26
,
positionCounter1
adds
1. Move one bit to the left through
lcd.scrollDisplayLeft()
. Make the LCD display array1[0] by
lcd.
6.11. Lesson 11 LCD1602
137
Содержание R3
Страница 1: ...SunFounder uno and mega kit www sunfounder com Jan 19 2022 ...
Страница 2: ......
Страница 6: ...iv ...
Страница 8: ...SunFounder uno and mega kit 2 CONTENTS ...
Страница 9: ...CHAPTER ONE COMPONENTS LIST 3 ...
Страница 10: ...SunFounder uno and mega kit 4 Chapter 1 Components List ...
Страница 11: ...SunFounder uno and mega kit 5 ...
Страница 12: ...SunFounder uno and mega kit 6 Chapter 1 Components List ...
Страница 13: ...SunFounder uno and mega kit 7 ...
Страница 14: ...SunFounder uno and mega kit 8 Chapter 1 Components List ...
Страница 27: ...SunFounder uno and mega kit 2 7 Capacitor 2 7 Capacitor 21 ...
Страница 62: ...SunFounder uno and mega kit 56 Chapter 2 Components Introduction ...
Страница 64: ...SunFounder uno and mega kit 58 Chapter 3 Download the Code ...
Страница 82: ...SunFounder uno and mega kit 76 Chapter 5 Add Libraries ...
Страница 135: ...SunFounder uno and mega kit 6 10 3 Schematic Diagram The schematic diagram 6 10 Lesson 10 Servo 129 ...
Страница 163: ...SunFounder uno and mega kit 6 15 3 Schematic Diagram The schematic diagram 6 15 Lesson 15 Humiture Sensor 157 ...
Страница 198: ...SunFounder uno and mega kit 6 21 2 Components 192 Chapter 6 For Mega2560 User ...
Страница 200: ...SunFounder uno and mega kit 6 21 4 Experimental Procedures Step 1 Build the circuit 194 Chapter 6 For Mega2560 User ...
Страница 218: ...SunFounder uno and mega kit 212 Chapter 7 For Uno User ...
Страница 221: ...SunFounder uno and mega kit 7 1 Lesson 1 Blinking LED 215 ...
Страница 231: ...SunFounder uno and mega kit 7 3 Lesson 3 Controlling LED by Button 225 ...
Страница 233: ...SunFounder uno and mega kit 7 3 Lesson 3 Controlling LED by Button 227 ...
Страница 237: ...SunFounder uno and mega kit 7 4 Lesson 4 Doorbell 231 ...
Страница 253: ...SunFounder uno and mega kit indigo and purple 7 7 Lesson 7 RGB LED 247 ...
Страница 260: ...SunFounder uno and mega kit 254 Chapter 7 For Uno User ...
Страница 262: ...SunFounder uno and mega kit 256 Chapter 7 For Uno User ...
Страница 327: ...SunFounder uno and mega kit 7 20 Lesson 20 Simple Creation Stopwatch 321 ...
Страница 350: ...SunFounder uno and mega kit 344 Chapter 7 For Uno User ...
Страница 370: ...SunFounder uno and mega kit Finally click the Upload Code button 364 Chapter 8 Play with Scratch ...
Страница 378: ...SunFounder uno and mega kit Breadboard LED Resistor 372 Chapter 8 Play with Scratch ...
Страница 385: ...SunFounder uno and mega kit 8 2 Projects 379 ...
Страница 386: ...SunFounder uno and mega kit Breadboard Resistor RGB LED 380 Chapter 8 Play with Scratch ...
Страница 390: ...SunFounder uno and mega kit 4 Ball3 sprite red 5 Ball4 sprite green 384 Chapter 8 Play with Scratch ...
Страница 393: ...SunFounder uno and mega kit Breadboard LCD1602 Potentiometer 8 2 Projects 387 ...
Страница 402: ...SunFounder uno and mega kit Breadboard 396 Chapter 8 Play with Scratch ...
Страница 408: ...SunFounder uno and mega kit Breadboard Button 402 Chapter 8 Play with Scratch ...
Страница 414: ...SunFounder uno and mega kit Breadboard Tilt Switch 408 Chapter 8 Play with Scratch ...
Страница 419: ...SunFounder uno and mega kit Breadboard Thermistor 8 2 Projects 413 ...
Страница 425: ...SunFounder uno and mega kit Breadboard Photoresistor Resistor 8 2 Projects 419 ...
Страница 436: ...SunFounder uno and mega kit Breadboard Servo 430 Chapter 8 Play with Scratch ...
Страница 446: ...SunFounder uno and mega kit Breadboard DC Motor 440 Chapter 8 Play with Scratch ...
Страница 448: ...SunFounder uno and mega kit Adjust the size and position of the sprite appropriately 442 Chapter 8 Play with Scratch ...
Страница 461: ...SunFounder uno and mega kit Breadboard Button 8 2 Projects 455 ...
Страница 481: ...SunFounder uno and mega kit Breadboard 8 2 Projects 475 ...
Страница 493: ...SunFounder uno and mega kit Breadboard Button 8 2 Projects 487 ...
Страница 504: ...SunFounder uno and mega kit Set the size to 50 498 Chapter 8 Play with Scratch ...
Страница 522: ...SunFounder uno and mega kit 516 Chapter 8 Play with Scratch ...
Страница 524: ...SunFounder uno and mega kit 518 Chapter 9 FAQ ...
Страница 526: ...SunFounder uno and mega kit 520 Chapter 10 Thank You ...