0. Ref
https://learn.adafruit.com/adafruit-16x2-character-lcd-plus-keypad-for-raspberry-pi/python-usage
1. 연결
RPi4 | I2C LCD 20x4 |
5V (2, 4) | VCC |
GND (6, 9, 14, ...) | GND |
SDA (3) | SDA |
SCL (5) | SCL |
2. 샘플 코드
import board
import busio
import adafruit_character_lcd.character_lcd_i2c as character_lcd
lcd_columns = 20
lcd_rows = 4
i2c = busio.I2C(board.SCL, board.SDA)
lcd = character_lcd.Character_LCD_I2C(i2c, lcd_columns, lcd_rows)
lcd.clear()
lcd.message = "Hello\nCircuitPython"
실행
python3 lcd.py
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/adafruit_bus_device/i2c_device.py", line 154, in __probe_for_device
self.i2c.writeto(self.device_address, b"")
File "/usr/local/lib/python3.7/dist-packages/busio.py", line 166, in writeto
return self._i2c.writeto(address, buffer, stop=stop)
File "/usr/local/lib/python3.7/dist-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 49, in writeto
self._i2c_bus.write_bytes(address, buffer[start:end])
File "/usr/local/lib/python3.7/dist-packages/Adafruit_PureIO/smbus.py", line 314, in write_bytes
self._device.write(buf)
OSError: [Errno 121] Remote I/O error
3. 연결확인
pi@raspberrypi:~ $ i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- 27 -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
4. 엘레파츠 블로그 확인
5. 샘플 코드 다운로드, 실행
git clone https://github.com/eleparts/RPi_I2C_LCD_driver
cd RPi_I2C_LCD_driver
python3 example.py
'IT > Platform' 카테고리의 다른 글
[FPGA] ZYBO Z7: UART (Pmod USBUART) (0) | 2022.02.12 |
---|---|
[FPGA] ZYBO Z7: Vivado (0) | 2022.02.11 |
[FPGA] Vivado License @CentOS & Windows 10 (0) | 2022.02.05 |
[FPGA] HDMI Solution (0) | 2022.02.03 |
[RPi] 4B Tips (0) | 2022.02.03 |