Sunteți pe pagina 1din 15

BATAN GAS S TATE UNIVERS ITY

COLLEGE OF ENGINEERING, ARCHITECTURE, AND FINE ARTS


Gov. Pablo Borbon Campus II, Alangilan, Batangas City, Philippines 4200
 
 (043)7220823 Fax No: (043)7238125 http:// www.batstate-u.edu.ph

ECE 416: MICROPROCESSOR

LABORATORY NO. 3
Raspberry Pi and LCD

Submitted by:
Caringal, Cherrielyn M.
Dimaculangan, Jhoven L.
Masangcay, Diether Jhay S.
Miranda, Anne Jeline H.
Torino, Cleo Martin R.

ECE- 4201

Submitted to:
Dr. Gil Barte
Instructor

April 13, 2019


I. INTRODUCTION

LCD (liquid crystal display) is the technology used for displays in notebook and other smaller
computers. Like light-emitting diode (LED) and gas-plasma technologies, LCDs allow displays to be
much thinner than cathode ray tube (CRT) technology. LCDs consume much less power than LED
and gas-display displays because they work on the principle of blocking light rather than emitting it.

The backlight in liquid crystal display provides an even light source behind the screen. This
light is polarized, meaning only half of the light shines through to the liquid crystal layer. The liquid
crystals are made up of a part solid, part liquid substance that can be "twisted" by applying electrical
voltage to them. They block the polarized light when they are off, but reflect red, green, or blue light
when activated.

Each LCD screen contains a matrix of pixels that display the image on the screen. Early
LCDs had passive-matrix screens, which controlled individual pixels by sending a charge to their row
and column. Since a limited number of electrical charges could be sent each second, passive-matrix
screens were known for appearing blurry when images moved quickly on the screen.

The basics of incorporating an LCD into the group’s project will be learned in this laboratory
experiment. The Raspberry Pi will allow simple text messages to be displayed on an LCD using the
Python programming language.

II. OBJECTIVES
The aim of this paper is to make necessary codes to perform the required tasks using Raspberry
Pi.
Specifically, this includes:

1. Connect the LCD to GPIO (General Purpose Input Output) pins of PI to display characters on
it.
2. Write a program in Python to send the appropriate commands to the LCD through GPIO and
display the needed characters on its screen.
3. Make a program where the Raspberry Pi is connected to a LCD character display and shows
the status of the LED with switch.
4. Make a program where the Raspberry Pi is connected to a LCD character display and shows
the status if the sensor (LDR) detects.

III. MATERIAL
The following materials will be needed to conduct the laboratory experiment:
 Raspberry Pi
 I2C LCD Display
 Header
 LED
 Push Button/ Module
 LDR
 10k resistor
 Several jumper wires (Male to Female)
 Laptop/PC
 LAN connector
 5-Volt supply to power Raspberry
IV. PROCEDURES, CODES AND PSEUDOCODES
A. LED with switch (STATUS)
1. As shown in figure connect the I2C lcd on raspberry pi

2. Connect the switch button on pin 40 and the LED on pin 38


3. Then use the program code as shown below
B. Sensor On/Off (STATUS)

1. Interface the circuit as shown below


C. Codes for Arduino

V. DATA AND RESULTS


LED with switch (STATUS)

Button not push LED status OFF


Sensor On/Off (STATUS)

Running the program on putty terminal

Display on LCD when LDR sense the light


VI. EXERCISE

Objective:
Create a program using a temperature sensor. Display the temperature on the LCD.

Procedure:

1. Raspbian should be upgraded to latest version in order to support RPI.GPIO module.


Please run following commands in shell:
 Sudo apt-get update
 Sudo apt-get upgrade

2. Enable I2C and SPI protocol:


sudo raspi-config

Then select Advance Options and enable I2C and SPI. After rebooting the Pi, we need to
modify the module’s config file. Type the following command in terminal:
sudo nano /etc/modules

Add following two lines in modules file if they do not exist:


i2c-bcm2708
i2c-dev

3. Install smbus and i2c python library. Then, type following command in terminal:
sudo apt-get update
sudo apt-get install -y python-smbus i2c-tools
sudo reboot

4. Raspberry Pi,I2C 1602 LCD and DHT11 sensor pin connection

LCD Pin Description Pi Function RasPi Pin

GND GND GND pin 6 or pin 39


VCC +5V/3.3v +3.3V pin 2
SDA SDA GPIO 02 pin 3
SCL SCL GPIO 03 pin 5
DHT11 DATA pin GPIO 14 pin 8
DHT11 +VCC pin +3V pin 1
DHT11 GND(-) GND pin 6
5. Testing Hardware
Depending on your Raspberry Pi version, please run one of following commands in
terminal:
sudo i2cdetect -y 1
or
sudo i2cdetect -y 0
You should see something as follows:
0123456789abcdef
0: —————————————
10: — — — — — — — — — — — — — — — —
20: — — — — — — — — — — — — — — — —
30: — — — — — — — — — — — — — — — 3f
40: — — — — — — — — — — — — — — — —
50: — — — — — — — — — — — — — — — —
60: — — — — — — — — — — — — — — — —
70: — — — — — — — —
If you can only see “– — –” sign in the list without any numbers, it means either your
circuit connection is wrong or your software is not properly installed.
Please take special attention on the “3f” in above result, this is the i2c address of your
LCD, it might be other value such as 27. If the value is not 3f, you need change line 18 of
file “pi-dht11-i2clcd.py” (you need download this file in Step 6 with wget command)

6. Download python code. Please typing following shell commands to download


python file(dht11.py):
sudo wget

http://osoyoo.com/driver/dht11.py Then the code

shown below:
Finally run the program by typing:
Sudo python3 temperature.py
VII. CONCLUSION

Communicating with the Raspberry Pi LCD 16×2 display is easy because of the library
provided by Adafruit. It is incredibly easy to write Python scripts to setup and alter the display.

Based on the experiment, it is easy to interface the LCD to Raspberry Pi although


many GPIO pin will be used in Raspberry Pi. When the LCD is added to any project it gives
a good way to monitor on what is happening on the system.

S-ar putea să vă placă și