[Note] Using 16x2-digit character LCD (1602A) from Python with Raspberry Pi

Qiita_LCD16x2-1.JPG

Overview

--Use Adafruit's Python library to display characters on a 16x2-digit character LCD known as 1602.
https://github.com/adafruit/Adafruit_Python_CharLCD --It's not an I2C connection ** --Any pin that can be used as GPIO on Raspberry Pi can be connected.

environment

procedure

Connect

LCD Pin :Raspberry Pi pin
 1 VSS * GND
 2 VDD * 5.0V
 3 V0  * (To the pin in the middle of the 10KΩ variable resistor. 5 at both ends of the variable resistor.0V and GND)
 4 RS  : GPIO22 (15th Pin)
 5 RW  : GND (H=Read/L=Since it is Write, Write Only)
 6 E   : GPIO26 (No. 37 Pin)
 7 D0  -Do not use NC
 8 D1  -Do not use NC
 9 D2  -Do not use NC
10 D3  -Do not use NC
11 D4  : GPIO5  (29th Pin)
12 D5  : GPIO6  (31st Pin)
13 D6  : GPIO13 (33rd Pin)
14 D7  : GPIO19 (No. 35 Pin)
15 A   * 5.0V
16 K   * GND
  1. Do not connect the power supply to the Raspberry Pi.
  2. Wire 5.0V, GND and variable resistors ** carefully </ font> **.
  3. Well, check it.
  4. Insert the power supply into the Raspberry Pi with the SD card removed, and try supplying 5.0V.
  5. Turn on the LCD backlight and turn the variable low to change the contrast.
  6. When the power is turned on, ■ is displayed in the upper row and nothing is displayed in the lower row.
  7. Unplug the power supply and wire the rest.
  8. Insert the SD card into the Raspberry Pi, turn the power off and then on again, and start up.

Qiita_LCD16x2-2.JPG

Library installation

sudo apt-get update
sudo apt-get install -y build-essential python-dev python-smbus python-pip git
sudo pip install RPi.GPIO
#
cd $HOME
#Git, Kuro-n.
git clone https://github.com/adafruit/Adafruit_Python_CharLCD.git
#
cd Adafruit_Python_CharLCD
#Installation
sudo python setup.py install

Try using it lightly

  1. Start Python with python [Enter]

  2. Code, copy

#Import this guy. import Adafruit_CharLCD as LCD #Pin settings.Enter the GPIO number lcd_rs = 22 lcd_en = 26 lcd_d4 = 5 lcd_d5 = 6 lcd_d6 = 13 lcd_d7 = 19

#16x2 digits. lcd_columns = 16 lcd_rows = 2

lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows) #LCD clear. lcd.clear() #Message display. lcd.message('Hello World!16x2\nQiita.com/mt08/') #Display the cursor and blink lcd.blink(True)


 3. Exit with `Ctrl-D`



## Other
 --When running ʻAdafruit_Python_CharLCD / examples / char_lcd.py`, open it in a text editor and change the pin settings to a good one.
 ――I have 5V, but is GPIO okay ?? <br> ... Maybe. .. .. Since the RW pin is set to GND and it is written only from the perspective of Raspberry Pi, it will not be output from the LCD side ...
 -If you look at [ʻAdafruit_CharLCD / Adafruit_CharLCD.py`](https://github.com/adafruit/Adafruit_Python_CharLCD/blob/master/Adafruit_CharLCD/Adafruit_CharLCD.py), you can see the commands that you can use ... `def` So you define it, right?
 --If you look at the WiringPi (http://wiringpi.com/dev-lib/lcd-library/), does C support it? Like

### Execution example

```py
pi@raspberrypi:~ $ python
Python 2.7.9 (default, Sep 17 2016, 20:26:04) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> #Import this guy.
... import Adafruit_CharLCD as LCD
>>> #Pin settings.Enter the GPIO number
... lcd_rs        = 22
>>> lcd_en        = 26
>>> lcd_d4        = 5
>>> lcd_d5        = 6
>>> lcd_d6        = 13
>>> lcd_d7        = 19
>>> #
... #16x2 digits.
... lcd_columns = 16
>>> lcd_rows    = 2
>>> #
... #
... lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7,
...                            lcd_columns, lcd_rows)
>>> #LCD clear.
... lcd.clear()
>>> #Message display.
... lcd.message('Hello World!16x2\nQiita.com/mt08/')
>>> #Display the cursor and blink
... lcd.blink(True)
>>> 
pi@raspberrypi:~ $ 

Recommended Posts

[Note] Using 16x2-digit character LCD (1602A) from Python with Raspberry Pi
Using a webcam with Raspberry Pi
Control the motor with a motor driver using python on Raspberry Pi 3!
Using the 1-Wire Digital Temperature Sensor DS18B20 from Python on a Raspberry Pi
Create an LCD (16x2) game with Raspberry Pi and Python
Detect "temperature (using A / D converter)" using python on Raspberry Pi 3!
SSD 1306 OLED can be used with Raspberry Pi + python (Note)
getrpimodel: Recognize Raspberry Pi model (A, B, B +, B2, B3, etc) with python
Use vl53l0x with Raspberry Pi (python)
Try to extract a character string from an image with Python3
[Note] Get data from PostgreSQL with Python
Detect "brightness" using python on Raspberry Pi 3!
How to upload a file to Cloud Storage using Python [Make a fixed point camera with Raspberry PI # 1]
Build a Tensorflow environment with Raspberry Pi [2020]
# 5 [python3] Extract characters from a character string
Run servomotor on Raspberry Pi 3 using python
Make a wash-drying timer with a Raspberry Pi
Operate an oscilloscope with a Raspberry Pi
Detect temperature using python on Raspberry Pi 3!
Create a car meter with raspberry pi
Working with GPS on Raspberry Pi 3 Python
Create a tool to automatically furigana with html using Mecab from Python3
Try tweeting arXiv's RSS feed on twitter from Raspberry Pi with python
I tried to make a traffic light-like with Raspberry Pi 4 (Python edition)
Discord bot with python raspberry pi zero with [Notes]
Detect slide switches using python on Raspberry Pi 3!
Try using a QR code on a Raspberry Pi
I tried L-Chika with Raspberry Pi 4 (Python edition)
[Note] Create a one-line timezone class with python
Send data from Raspberry Pi using AWS IOT
Use Majoca Iris elongated LCD with Raspberry Pi
Get CPU information of Raspberry Pi with Python
Sound the buzzer using python on Raspberry Pi 3!
Create a decision tree from 0 with Python (1. Overview)
Run a Python file from html using Django
Create a visitor notification system using Raspberry Pi
Read line by line from a file with Python
Run a python script from excel (using xlwings)
Connect to MySQL with Python on Raspberry Pi
Build a Python development environment on Raspberry Pi
Extract data from a web page with Python
GPS tracking with Raspberry Pi 4B + BU-353S4 (Python)
Measure CPU temperature of Raspberry Pi with Python
[Raspberry Pi] Publish a web application on https using Apache + WSGI + Python Flask
Creating a temperature control system with Raspberry Pi and ESP32 (3) Recipient Python file
From setting up Raspberry Pi to installing Python environment
Create a color sensor using a Raspberry Pi and a camera
Using the digital illuminance sensor TSL2561 with Raspberry Pi
A real way for people using python 3.8.0-2 from windows to work with multibyte characters
GPGPU with Raspberry Pi
Using Akizuki Denshi's 4WD car FT-MC-004 with Raspberry Pi
Try debugging Python on Raspberry Pi with Visual Studio.
[Python] Create a ValueObject with a complete constructor using dataclasses
Install PyCall on Raspberry PI and try using GPIO's library for Python from Ruby
DJango Note: From the beginning (using a generic view)
Register a ticket with redmine API using python requests
From buying a computer to running a program with python
Ubuntu 20.04 on raspberry pi 4 with OpenCV and use with python
Face detection from images taken with Raspberry Pi camera
Principal component analysis using python from nim with nimpy
DigitalSignage with Raspberry Pi