User Manual

115
lcdPosition(fd, 0, 0) // Locate the position of the cursor at Row 0 and Col 0 (in fact
it's the first line and first column)
lcdPuts(fd, "Welcom To--->") // Display the character "Welcom To--->"on the LCD1602
lcdPosition(fd, 0, 1); // Place the cursor at Col 0, Row 0.
lcdPuts(fd, " sunfounder.com");
while(1){
lcdClear(fd);
for(i=0; i<16; i++){ // i adds one in the loop. i means the number of columns, so i
adds to 16 at most.
lcdPosition(fd, i, 0); // Place the cursor at the first row, and moves left to
right from the first character
lcdPutchar(fd, *(myBuf+i)); // *(myBuf+i) is a pointer that points to contents in
the myBuf[] array, and output the pointed data to lcd
delay(100);
}
for(i=0;i<sizeof(Buf)-1;i++){
lcdPosition(fd, i, 1); // Place the cursor at the second row, moves from the
first character
lcdPutchar(fd, *(Buf+i)); // A pointer that points to data in the Buf[] array;
output it to lcd
delay(200);
}
sleep(0.5);
}
For Python users
Step 2: Get into the folder of code
cd /home/pi/SunFounder_Super_Kit_V3.0_for_Raspberry_Pi/Python
Step 3: Run
sudo python 16_lcd1602.py
Code Explanation
class LCD: # Write an LCD class
def __init__(self, pin_rs=27, pin_e=22, pins_db=[25, 24, 23, 18], GPIO = None):
# Initialization function for the class, run when an object is created of the class. A
parameter needs to be transferred to the object when it's created; otherwise, the
default value in __init__ will be assigned.
SunFounder