How to do it...

  1. Create the following script, called lcd_i2c.py:
#!/usr/bin/python3 #lcd_i2c.py import wiringpi2 import time import datetime import data_local as dataDevice AF_BASE=100 AF_E=AF_BASE+13; AF_RW=AF_BASE+14; AF_RS=AF_BASE+15 AF_DB4=AF_BASE+12; AF_DB5=AF_BASE+11; AF_DB6=AF_BASE+10 AF_DB7=AF_BASE+9 AF_SELECT=AF_BASE+0; AF_RIGHT=AF_BASE+1; AF_DOWN=AF_BASE+2 AF_UP=AF_BASE+3; AF_LEFT=AF_BASE+4; AF_BACK=AF_BASE+5 AF_GREEN=AF_BASE+6; AF_BLUE=AF_BASE+7; AF_RED=AF_BASE+8 BNK=" "*16 #16 spaces def gpiosetup(): global lcd wiringpi2.wiringPiSetup() wiringpi2.mcp23017Setup(AF_BASE,0x20) wiringpi2.pinMode(AF_RIGHT,0) wiringpi2.pinMode(AF_LEFT,0) wiringpi2.pinMode(AF_SELECT,0) wiringpi2.pinMode(AF_RW,1) wiringpi2.digitalWrite(AF_RW,0) lcd=wiringpi2.lcdInit(2,16,4,AF_RS,AF_E, ...

Get Raspberry Pi 3 Cookbook for Python Programmers - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.