Joy-it RB-LCD-16x2 User manual

Published: 22.08.2019 Copyright by Joy-IT 1
3LCD Display 20x4 with Buttons
LCD Display 16x2 with Buttons
3

Published: 22.08.2019 Copyright by Joy-IT 2
3LCD Display 20x4 with Buttons
Index
1. Connecng the Display
2. Installing the System
3. Usage & Example-Code
3.1. RB-LCD16x2 - Version 1
3.2. RB-LCD16x2-V2
4. Support

Published: 22.08.2019 Copyright by Joy-IT 3
3LCD Display 20x4 with Buttons
Dear customer
thank you for purchasing our product.
Please nd our instrucons below:
1. Connecting the Display
Plug the display onto the pin header of your Raspberry Pi so that the display is placed over your
Raspberry Pi.
As soon as you power your Raspberry Pi, the displays backlight should start to light.

Published: 22.08.2019 Copyright by Joy-IT 4
3LCD Display 20x4 with Buttons
2. Installing the System
You can skip this step, if you are already running the latest Raspbian soware on your Raspberry Pi,
and connue with the next step.
If not, please follow the instrucons.
Install the latest Raspbian-System-Image to your SD-Card.
You can download the image here.
Transfer the image with a suitable program (e.g. Etcher).
You can insert the SD-Card to your Raspberry Pi and start the system when the transfer progress is
complete.

Published: 22.08.2019 Copyright by Joy-IT 5
3LCD Display 20x4 with Buttons
3. Verwendung & Code-Beispiel
Before using our RB-LCD16x2 you need to determine which version you own.
The following two pictures show you how to recognize this.
RB LCD16x2
Connued from page 6
RB-LCD16x2 Version 2
Connued from page 10
16x2

Published: 22.08.2019 Copyright by Joy-IT 6
3LCD Display 20x4 with Buttons
3.1. RB-LCD16x2 - Version 1
The display is ready for use aer connecon and requires no further installaon.
You may need to adjust the contrast manually before you can see an output on the display.
Adjust the contrast by turning the adjusng screw with a small screwdriver.
To get the display fully up and running, you can either download the example code here, or even
create a new le and paste the code below.
To create a new le, use the following command:
sudo nano lcd16x2-V1.py

Published: 22.08.2019 Copyright by Joy-IT 7
3LCD Display 20x4 with Buttons
import time
import RPi.GPIO as GPIO
# PIN-Configuration
LCD_RS = 7 #GPIO7 = Pi pin 26
LCD_E = 8 #GPIO8 = Pi pin 24
LCD_D4 = 17 #GPIO17 = Pi pin 11
LCD_D5 = 18 #GPIO18 = Pi pin 12
LCD_D6 = 27 #GPIO21 = Pi pin 13
LCD_D7 = 22 #GPIO22 = Pi pin 15
OUTPUTS = [LCD_RS,LCD_E,LCD_D4,LCD_D5,LCD_D6,LCD_D7]
#Button-PINs
SW1 = 4 #GPIO4 = Pi pin 7
SW2 = 23 #GPIO16 = Pi pin 16
SW3 = 10 #GPIO10 = Pi pin 19
SW4 = 9 #GPIO9 = Pi pin 21
INPUTS = [SW1,SW2,SW3,SW4]
#HD44780 Controller Commands
CLEARDISPLAY = 0x01
SETCURSOR = 0x80
#Line Addresses. (Pick one. Comment out whichever doesn't apply)
#LINE = [0x00,0x40,0x14,0x54] #for 20x4 display
LINE = [0x00,0x40] #for 16x2 display
########################################################################
def InitIO():
#Sets GPIO pins to input & output, as required by LCD board
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
for lcdLine in OUTPUTS:
GPIO.setup(lcdLine, GPIO.OUT)
for switch in INPUTS:
GPIO.setup(switch, GPIO.IN, pull_up_down=GPIO.PUD_UP)
def CheckSwitches():
#Check status of all four switches on the LCD board
val1 = not GPIO.input(SW1)
val2 = not GPIO.input(SW2)
val3 = not GPIO.input(SW3)
val4 = not GPIO.input(SW4)
return (val4,val1,val2,val3)

Published: 22.08.2019 Copyright by Joy-IT 8
3LCD Display 20x4 with Buttons
def PulseEnableLine():
#Pulse the LCD Enable line; used for clocking in data
mSec = 0.0005 #use half-millisecond delay
time.sleep(mSec) #give time for inputs to settle
GPIO.output(LCD_E, GPIO.HIGH) #pulse E high
time.sleep(mSec)
GPIO.output(LCD_E, GPIO.LOW) #return E low
time.sleep(mSec) #wait before doing anything else
def SendNibble(data):
#sends upper 4 bits of data byte to LCD data pins D4-D7
GPIO.output(LCD_D4, bool(data & 0x10))
GPIO.output(LCD_D5, bool(data & 0x20))
GPIO.output(LCD_D6, bool(data & 0x40))
GPIO.output(LCD_D7, bool(data & 0x80))
def SendByte(data,charMode=False):
#send one byte to LCD controller
GPIO.output(LCD_RS,charMode) #set mode: command vs. char
SendNibble(data) #send upper bits first
PulseEnableLine() #pulse the enable line
data = (data & 0x0F)<< 4 #shift 4 bits to left
SendNibble(data) #send lower bits now
PulseEnableLine() #pulse the enable line
def InitLCD():
#initialize the LCD controller & clear display
SendByte(0x33) #initialize
SendByte(0x32) #set to 4-bit mode
SendByte(0x28) #2 line, 5x7 matrix
SendByte(0x0C) #turn cursor off (0x0E to enable)
SendByte(0x06) #shift cursor right
SendByte(CLEARDISPLAY) #remove any stray characters on display
########################################################################
def SendChar(ch):
SendByte(ord(ch),True)
def ShowMessage(string):
#Send string of characters to display at current cursor position
for character in string:
SendChar(character)

Published: 22.08.2019 Copyright by Joy-IT 9
3LCD Display 20x4 with Buttons
def GotoLine(row):
#Moves cursor to the given row
#Expects row values 0-1 for 16x2 display; 0-3 for 20x4 display
addr = LINE[row]
SendByte(SETCURSOR+addr)
########################################################################
# Main Program
print "LCD program starting. Press CTRL+C to stop."
InitIO()
InitLCD()
ShowMessage('Press a button!')
while (True):
GotoLine(1)
switchValues = CheckSwitches()
decimalResult = " %d %d %d %d" % switchValues
ShowMessage(decimalResult)
# time.sleep(0.2)
You can save the le with the keyboard shortcut CTRL + O and exit the editor with CTRL + X.
You can then execute the le with the following command:
sudo python lcd16x2-V1.py

Published: 22.08.2019 Copyright by Joy-IT 10
3LCD Display 20x4 with Buttons
3.2. RB-LCD16x2-V2
To get the display up and running, you must rst install a library for the display. You can do this in the
console with the following command:
It may be necessary to manually adjust the contrast before you can see an output on the display.
Adjust the contrast by turning the potenometer with a small screwdriver, which is marked "red" in
the lower picture.
sudo pip install adafruit-charlcd

Published: 22.08.2019 Copyright by Joy-IT 11
3LCD Display 20x4 with Buttons
Before using the display, "I²C" must be acvated.
You can do this with the following command in the Raspberry Cong:
Select the opon "Interfacing Opons" with the key "Enter":
Then you have to select the opon "I2C":
You have to conrm the next message with Yes and then you can leave the sengs on "Finish". I2C is
now successfully acvated, now the display can be used.
sudo raspi-config

Published: 22.08.2019 Copyright by Joy-IT 12
3LCD Display 20x4 with Buttons
from Adafruit_CharLCD import Adafruit_CharLCD
import Adafruit_GPIO.PCF8574 as PCF
GPIO = PCF.PCF8574(address=0x27)
GPIO.setup(5,0)
GPIO.output(5,0)
# Define PCF pins connected to the LCD.
lcd_rs = 4
lcd_en = 7
d4,d5,d6,d7 = 0,1,2,3
cols,lines = 16,2
# Instantiate LCD Display
lcd = Adafruit_CharLCD(lcd_rs, lcd_en, d4, d5, d6, d7,cols, lines, gpio=GPIO)
lcd.clear()
lcd.message('xx RB-LCDV2 Test xx\n 1234567890')
You can save the le with the keyboard shortcut CTRL + O and exit the editor with CTRL + X.
You can then execute the le with the following command:
sudo python lcd16x2-V2.py
You can either download the sample code or create a new one yourself and paste the code below.
To create a new le, use the following command:
sudo nano lcd16x2-V2.py

Published: 22.08.2019 Copyright by Joy-IT 13
3LCD Display 20x4 with Buttons
4. Support
We also support you aer your purchase.
If there are any quesons le or if you encounter any problems, please feel free to contact us by mail,
phone or by our cket-supportsystem on our website.
E-Mail: service@joy-it.net
Ticket-System: hp://support.joy-it.net
Phone: +49 (0)2845 98469 – 66 (11- 18 Uhr)
Please visit our website for more informaons:
www.joy-it.net
Other manuals for RB-LCD-16x2
2
This manual suits for next models
1
Table of contents
Other Joy-it Monitor manuals

Joy-it
Joy-it RB-TFT3.5 User manual

Joy-it
Joy-it RB-TFT3.2 User manual

Joy-it
Joy-it RB-LCD-16x2 User manual

Joy-it
Joy-it RB-LCD10-2 User manual

Joy-it
Joy-it 84X48 LCD DISPLAY User manual

Joy-it
Joy-it RB-LCD-10B User manual

Joy-it
Joy-it RB-LCD-20x4 User manual

Joy-it
Joy-it SBC-LCD01 User manual

Joy-it
Joy-it RB-LCD5 User manual

Joy-it
Joy-it 1656364 User manual