{"id":36,"date":"2013-07-31T15:53:15","date_gmt":"2013-07-31T15:53:15","guid":{"rendered":"http:\/\/blog.soton.ac.uk\/pi\/?page_id=36"},"modified":"2013-08-23T15:08:45","modified_gmt":"2013-08-23T15:08:45","slug":"adafruit-rgb-lcd-display","status":"publish","type":"page","link":"https:\/\/blog.soton.ac.uk\/pi\/modules-available\/adafruit-rgb-lcd-display\/","title":{"rendered":"Adafruit RGB\/BLue&amp;White LCD Display"},"content":{"rendered":"<h1>1) Overview<\/h1>\n<p>&nbsp;<\/p>\n<div>\n<div><a href=\"http:\/\/learn.adafruit.com\/assets\/2620\"> <img loading=\"lazy\" decoding=\"async\" title=\"RGB Positive LCD\" alt=\"1109_LRG.jpg\" src=\"http:\/\/learn.adafruit.com\/system\/assets\/assets\/000\/002\/620\/medium800\/1109_LRG.jpg?1360798080\" width=\"800\" height=\"615\" \/><\/a><\/div>\n<\/div>\n<div><\/div>\n<div>This Adafruit plate makes it easy to use a 16&#215;2 Character LCD. Unfortunately, these LCDs do require quite a few digital pins, 6 to control the LCD and then perhaps another 3 to control the RGB backlight for a total of 9 pins. That&#8217;s nearly all the GPIO available on a Raspberry Pi!\u00a0<strong><\/strong>You will either have a RGB LCD Plate or a Blue &amp; White one. The functionality for the two is similar, the only difference is in the colours displayed. You can recognise easily that you have a RGB or Blue&amp;White one by looking at the number of soldered pins above the screen. The RGB one has 18, while the Blue&amp;White one has 16.<\/div>\n<div>\n<div><a href=\"http:\/\/learn.adafruit.com\/assets\/2622\">\u00a0 <\/a><\/div>\n<\/div>\n<p>This plate is perfect for when you want to build a stand-alone project with its own user interface. The 4 directional buttons plus select button allows basic control without having to attach a bulky computer.<\/p>\n<h1>2) Usage<\/h1>\n<p>Plug the LCD Plate onto the Pi, using the 26-pin GPIO header such that the LCD Plate will rest above the Raspberry Pi, as shown in below:<\/p>\n<p><a href=\"http:\/\/blog.soton.ac.uk\/pi\/files\/2013\/07\/LCDPlate.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-120\" alt=\"LCDPlate\" src=\"http:\/\/blog.soton.ac.uk\/pi\/files\/2013\/07\/LCDPlate-300x155.png\" width=\"540\" height=\"293\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<div>The backlights will not turn on until you have the code running so don&#8217;t be alarmed if nothing lights up when you plug in the plate! If you have a &#8216;positive&#8217; style LCD, you may see some squares on the first line, that&#8217;s normal.<\/div>\n<div>\n<h1>Setting up your Pi for I2C<\/h1>\n<p>For a more basic introduction to setting up I2C on your Pi then you may wish to take a diversion to this Adafruit tutorial: \u00a0<a title=\"Link: http:\/\/learn.adafruit.com\/adafruits-raspberry-pi-lesson-4-gpio-setup\/configuring-i2c\" href=\"http:\/\/learn.adafruit.com\/adafruits-raspberry-pi-lesson-4-gpio-setup\/configuring-i2c\">http:\/\/learn.adafruit.com\/adafruits-raspberry-pi-lesson-4-gpio-setup\/configuring-i2c<\/a><\/p>\n<p>Type in the command <b>sudo nano \/etc\/modules <\/b>in order to edit &#8220;modules&#8221; file and add the following lines:<\/p>\n<p>&nbsp;<\/p>\n<p><strong>i2c-bcm2708<\/strong><\/p>\n<\/div>\n<div><strong>i2c-dev<\/strong><\/div>\n<div><\/div>\n<div>\n<p>to the end of the file. Then save the file and reboot the Pi (type\u00a0<strong>sudo reboot\u00a0<\/strong>in the terminal) to enable the hardware I2C driver.<\/p>\n<p>Before you can get started with I2C on the Pi, you&#8217;ll need to run through a couple quick steps from the console. Just enter the following commands to add SMBus support\u00a0(which includes I2C) to Python:<\/p>\n<p>&nbsp;<\/p>\n<\/div>\n<div>\n<ol>\n<li><strong>sudo apt-get install python-smbus<\/strong><\/li>\n<li><strong>sudo apt-get install i2c-tools<\/strong><\/li>\n<\/ol>\n<\/div>\n<div>i2c-tools isn&#8217;t strictly required, but it&#8217;s a useful package since you can use it to scan for any I2C or SMBus devices connected to your board. \u00a0If you know something is connected, but you don&#8217;t know it&#8217;s 7-bit I2C address, this library has a great little tool to help you find it:<\/div>\n<div><\/div>\n<div>\n<div><\/div>\n<ol>\n<li><strong>sudo i2cdetect -y 0 (if you are using a version 1 Raspberry Pi)<\/strong><\/li>\n<li><strong>sudo i2cdetect -y 1 (if you are using a version 2 Raspberry Pi)<\/strong><\/li>\n<\/ol>\n<\/div>\n<div>\n<div><a href=\"http:\/\/learn.adafruit.com\/assets\/2664\"> <img decoding=\"async\" alt=\"i2cdetect.gif\" src=\"http:\/\/learn.adafruit.com\/system\/assets\/assets\/000\/002\/664\/medium800\/i2cdetect.gif?1353533987\" \/> <\/a><\/div>\n<\/div>\n<div>This will search \/dev\/i2c-0 or \/dev\/i2c-1 for all address, and if an Adafruit LCD Plate is connected, it should show up at <b>0x20, <\/b>as per the figure above. Once both of these packages have been installed, you have everything you need to get started accessing I2C and SMBus devices in\u00a0Python.<\/div>\n<div>\n<h1>Using the example Python code<\/h1>\n<p>The easiest way to get the code onto your Pi is to hook up an Ethernet cable, and clone it directly using &#8216;<strong>git<\/strong>&#8216;. Simply run the following commands from an appropriate location (ex. &#8220;\/home\/pi&#8221;):<\/p>\n<\/div>\n<div>\n<div><\/div>\n<ol>\n<li><strong>sudo apt-get install git<\/strong><\/li>\n<li><strong>git clone https:\/\/github.com\/adafruit\/Adafruit-Raspberry-Pi-Python-Code.git<\/strong><\/li>\n<li><strong>cd Adafruit-Raspberry-Pi-Python-Code<\/strong><\/li>\n<li><strong>cd Adafruit_CharLCDPlate<\/strong><\/li>\n<\/ol>\n<\/div>\n<div>You will also need to install RPi.GPIO, the python library for Pi that allows easy GPIO access. On Raspbian, just run:<\/div>\n<div><\/div>\n<div><strong>sudo apt-get install python-dev<\/strong><\/div>\n<div><strong>sudo apt-get install python-rpi.gpio<\/strong><\/div>\n<div><\/div>\n<div>\n<h1>Testing the Library<\/h1>\n<p>Once the code has been downloaded to\u00a0an appropriate folder, and you have your LCD Plate properly connected, you can start with the basic demo display, which is run by simply executing the library file:<\/p>\n<\/div>\n<div>\n<div><\/div>\n<ol>\n<li><strong>sudo python Adafruit_CharLCDPlate.py<\/strong><\/li>\n<\/ol>\n<\/div>\n<div>If you have a rev 2 (512MB) Pi, or if you&#8217;re not getting anything displaying, it might be due to the I2C bus number change in the Pi hardware. Edit Adafruit_CharLCD.py using a command like &#8220;<strong>nano Adafruit_CharLCD.py<\/strong>&#8221; and change the line:<\/div>\n<div><\/div>\n<div><strong>lcd = Adafruit_CharLCDPlate(busnum = 0)<\/strong><\/div>\n<div>to<\/div>\n<div><strong>lcd = Adafruit_CharLCDPlate(busnum = 1)<\/strong><\/div>\n<div><\/div>\n<div>\n<h1>Adjusting Contrast<\/h1>\n<p>The plate uses a character LCD with an external yellow contrast potentiometer. The first time you use it, adjust the potentiometer in the bottom right (with a screwdriver or something similar) until you see the text clearly. If you don&#8217;t upload code to the Pi, some boxes may appear instead, or you may see nothing at all.<\/p>\n<\/div>\n<h1>Using the library code<\/h1>\n<p>Interfacing with the python example code is fairly easy! Inside the Adafruit_CharLCDPlate folder you&#8217;ll find a <b>testLCD.py<\/b> python script. The script does a few things, at the top it imports all the sub-modules. You&#8217;ll need to have the<b> Adafruit_I2C.py<\/b>, <b>Adafruit_MCP230xx.py<\/b> and <b>Adafruit_CharLCDPlate.py<\/b> python files to be in the same directory so be sure to copy them to your final destination.<\/p>\n<p>Next it initializes the plate with<b> lcd = Adafruit_CharLCDPlate()<\/b> &#8211; this creates the lcd object and starts communicating with the plate to set up the LCD and buttons. After initialization, you can clear the display with <b>lcd.clear() <\/b>and write text with <b>lcd.message(&#8220;text goes here&#8221;)<\/b> don&#8217;t forget that its only 16 characters per line, and it does not automatically wrap lines. To insert a newline use the special &#8216;\\n&#8217; character such as shown in the command: <b>lcd.message(&#8220;Adafruit RGB LCD\\nPlate w\/Keypad!&#8221;). <\/b>Next you can set the backlight with <b>lcd.backlight(lcd.COLORNAME)<\/b> where\u00a0<b>COLORNAME<\/b> is RED, YELLOW, GREEN, TEAL, BLUE, VIOLET for RGB LCD&#8217;s or for monochrome LCDs, just use ON and OFF.<\/p>\n<p>Finally, you can ask the plate which buttons are pressed with <b>buttonPressed(lcd.BUTTONNAME)<\/b> where BUTTONNAME is <b>LEFT RIGHT UP DOWN <\/b>or <b>SELECT<\/b>. This is not an interrupt-driven library so you can&#8217;t have an interrupt go off when a button in pressed, instead you&#8217;ll have to query the button in a loop.<\/p>\n<p>That&#8217;s it! If you want to make detailed messages, <a href=\"http:\/\/www.diveintopython.net\/native_data_types\/formatting_strings.html\">use the python string formatting commands to create a string<\/a> and then write that string with <b>message()<\/b><\/p>\n<p><!--\nP { margin-bottom: 0.21cm; }A:link {  }\n--><a href=\"http:\/\/learn.adafruit.com\/adafruit-16x2-character-lcd-plus-keypad-for-raspberry-pi\/usage\">http:\/\/learn.adafruit.com\/adafruit-16&#215;2-character-lcd-plus-keypad-for-raspberry-pi\/usage<\/a><\/p>\n<p>&nbsp;<\/p>\n<p><b>3) Connectivity test<\/b><\/p>\n<p>Here is a python script which can test the internet connectivity on your raspberry pi and display whether there is internet connection, by pinging google. It also displays the Pi`s IP Address on the screen.<\/p>\n<p>The code has been adapted from James Wooley`s &#8220;Raspberry PI Pentesting Dropbox Slypi&#8221; described here: http:\/\/www.youtube.com\/watch?v=XkT__rRgLc8 and which can be found here &#8220;<a title=\"https:\/\/github.com\/Xtrato\/Slypi\" href=\"https:\/\/github.com\/Xtrato\/Slypi\" target=\"_blank\" rel=\"nofollow\">https:\/\/github.com\/Xtrato\/Slypi<\/a><\/p>\n<p>To test your internet connection, simply copy and paste the following code into a new python script and save the script in the folder &#8220;Adafruit_CharLCDPlate&#8221; from the previous chapter. You can do this by the following steps:<\/p>\n<p>a) Navigate to the directory <strong>Adafruit-Raspberry-Pi-Python-Code\/Adafruit_CharLCDPlate.\u00a0<\/strong>If you are in \/home,\u00a0 type:<\/p>\n<ol>\n<li><strong>cd Adafruit-Raspberry-Pi-Python-Code<\/strong><\/li>\n<li><strong>cd Adafruit_CharLCDPlate<\/strong><\/li>\n<\/ol>\n<p>If you did the previous example, you should already be located in this directory<\/p>\n<p>b) Open a new python script by typing <strong>nano ConnectivityTest.py <\/strong>(instead of &#8220;ConnectivityTest&#8221; you can give it any name). A blank file will open in the terminal. Copy and paste the code into this blank file and then save it and close using the\u00a0<strong>Ctrl+x\u00a0<\/strong>command.<\/p>\n<p>c) Type <strong>sudo python ConnectivityTest.py <\/strong>in the terminal. The LCD should show &#8220;Connectivity Test&#8221; written on the screen. Press &#8220;Select&#8221; and, if there is connectivity test, a green display should pop-up saying &#8220;Testing Connectivity&#8221; followed by a yellow screen which will display the IP address of the PI as well as the IP address of ? ?<\/p>\n<p>d) Press <strong>Ctrl+c <\/strong>to return to the command line<\/p>\n<p>&nbsp;<\/p>\n<div id=\"divBdy\">\n<div>\n<div>\n<div dir=\"ltr\">\n<div>\n<div>\n<div>\n<div>\n<div>#!\/usr\/bin\/python<\/div>\n<div>from socket import socket, SOCK_DGRAM, AF_INET<\/div>\n<div>import string<\/div>\n<div>import os<\/div>\n<div>import sys<\/div>\n<div>from time import sleep<\/div>\n<div>from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate<\/div>\n<div>import subprocess<\/div>\n<div>import urllib #Used to display the Public IP address.<\/div>\n<div>from subprocess import PIPE<\/div>\n<div><\/div>\n<div># Initialize the LCD plate. \u00a0Should auto-detect correct I2C bus. \u00a0If not,<\/div>\n<div># pass &#8216;0&#8217; for early 256 MB Model B boards or &#8216;1&#8217; for all later versions<\/div>\n<div>lcd = Adafruit_CharLCDPlate(busnum = 1)<\/div>\n<\/div>\n<div><\/div>\n<div>def connectivityTest():<\/div>\n<div>\u00a0 \u00a0 print &#8216;Connectivity Test&#8217;<\/div>\n<div>\u00a0 \u00a0 #Pings google.com<\/div>\n<div>\u00a0 \u00a0 thePing = subprocess.Popen(&#8216;ping -c 5 google.com&#8217;, shell=True, stdout=PIPE, stderr=PIPE)<\/div>\n<div>\u00a0 \u00a0 lcd.clear()<\/div>\n<div>\u00a0 \u00a0 lcd.backlight(lcd.GREEN)<\/div>\n<div>\u00a0 \u00a0 lcd.message(&#8220;Testing\\nConnectivity&#8221;)<\/div>\n<div>\u00a0 \u00a0 pingOut, pingErr = thePing.communicate()<\/div>\n<div>\u00a0 \u00a0 #If the ping fails ping 8.8.8.8<\/div>\n<div>\u00a0 \u00a0 lcd.clear()<\/div>\n<div>\u00a0 \u00a0 if len(pingErr) &gt; 0:<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 lcd.backlight(lcd.RED)<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 thePing = subprocess.Popen(&#8216;ping -c 5 8.8.8.8&#8217;, shell=True, stdout=PIPE, stderr=PIPE)<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 pingOut, pingErr = thePing.communicate()<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 print 1<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 #If pinging 8.8.8.8 fails display there is no internet connection<\/div>\n<\/div>\n<div><\/div>\n<div>if len(pingErr) &gt; 0:<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 lcd.message(&#8220;No Internet\\nConnection&#8221;)<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 print 2<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 #If pinging 8.8.8.8 succeeds, display there is no DHCP service available for the SlyPi to use.<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 else:<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 lcd.message(&#8220;No DHCP\\n Available&#8221;)<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 print 3<\/div>\n<div>\u00a0 \u00a0 else:<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 privateIP = getPrivateIP()<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 publicIP = getPublicIP()<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 lcd.backlight(lcd.YELLOW)<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 print privateIP<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 print publicIP<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 #Displays the public and private IP addresses on the LED screen.<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 lcd.message(privateIP + &#8216;\\n&#8217; + publicIP)<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 sleep(3)<\/div>\n<\/div>\n<div>funtionBreak()<\/div>\n<div><\/div>\n<div>def funtionBreak():<\/div>\n<div>\u00a0 \u00a0 while lcd.buttonPressed(lcd.LEFT):<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 os.execl(&#8216;slypi.py&#8217;, &#8221;)<\/div>\n<div><\/div>\n<div>def errorCheck(error, failedMessage, succeedMessage):<\/div>\n<div>\u00a0 \u00a0 lcd.clear()<\/div>\n<div>\u00a0 \u00a0 if &#8216;brctl: not found&#8217; in error:<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 lcd.backlight(lcd.RED)<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 lcd.message(&#8220;Failed\\nInstall brctl&#8221;)<\/div>\n<div>\u00a0 \u00a0 elif len(error[1]) == 0:<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 lcd.backlight(lcd.GREEN)<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 lcd.message(succeedMessage)<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 sleep(3)<\/div>\n<div>\u00a0 \u00a0 elif len(error[1]) &gt; 0:<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 lcd.backlight(lcd.RED)<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 lcd.message(failedMessage)<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 sleep(2)<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 os.execl(&#8216;slypi.py&#8217;, &#8221;)<\/div>\n<div>\u00a0 \u00a0 error = 0<\/div>\n<div><\/div>\n<div>def getPublicIP():<\/div>\n<div>\u00a0 \u00a0 publicIPUrl = urllib.urlopen(&#8220;http:\/\/my-ip.heroku.com\/&#8221;)<\/div>\n<div>\u00a0 \u00a0 return publicIPUrl.read()<\/div>\n<div><\/div>\n<div>def getPrivateIP():<\/div>\n<div>\u00a0 \u00a0 s = socket(AF_INET, SOCK_DGRAM)<\/div>\n<div>\u00a0 \u00a0 s.connect((&#8216;google.com&#8217;, 0))<\/div>\n<div>\u00a0 \u00a0 privateIp = s.getsockname()<\/div>\n<div>\u00a0 \u00a0 return privateIp[0]<\/div>\n<\/div>\n<div><\/div>\n<div>\n<div>#Contains all modules which can be run on the device. The key is the displayed name on the LCD and the value is the function name<\/div>\n<div>modules = {&#8216;Connectivity\\nTest&#8217;: &#8216;connectivityTest&#8217;}<\/div>\n<div>displayText = modules.keys()<\/div>\n<div># Clears the display<\/div>\n<div>lcd.clear()<\/div>\n<div># Checks if the script has been run as root.<\/div>\n<div>if os.getuid() == 0:<\/div>\n<div>\u00a0 \u00a0 menuOption = 0<\/div>\n<div>\u00a0 \u00a0 #lcd.backlight(lcd.BLUE)<\/div>\n<div>\u00a0 \u00a0 lcd.message(&#8220;SlyPi\\nPress Select&#8221;)<\/div>\n<div>else:<\/div>\n<div>\u00a0 \u00a0 lcd.backlight(lcd.BLUE)<\/div>\n<div>\u00a0 \u00a0 lcd.message(&#8220;Be sure to\\nRun as root&#8221;)<\/div>\n<div><\/div>\n<div>#The following while loop controls the LCD menu and the control using the keypad through the menu.<\/div>\n<\/div>\n<div>while True:<\/div>\n<div>\u00a0 \u00a0 if lcd.buttonPressed(lcd.SELECT):<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 sleep(0.5)<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 lcd.clear()<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 lcd.message(displayText[menuOption])<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 while True:<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 lcd.backlight(lcd.BLUE)<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 if lcd.buttonPressed(lcd.DOWN):<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 menuOption = menuOption + 1<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 if menuOption &gt; len(modules) &#8211; 1:<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 menuOption = 0<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 lcd.clear()<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 lcd.message(displayText[menuOption])<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 sleep(0.5)<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 if lcd.buttonPressed(lcd.UP):<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 menuOption = menuOption &#8211; 1<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 if menuOption &lt; 0:<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 menuOption = len(modules) &#8211; 1<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 lcd.clear()<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 lcd.message(displayText[menuOption])<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 sleep(0.5)<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 if lcd.buttonPressed(lcd.SELECT):<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 globals().get(modules[displayText[menuOption]])()<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 sleep(0.5)<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 break<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 if lcd.buttonPressed(lcd.LEFT):<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 print &#8220;left&#8221;<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 menuOption = 0<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 break<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>1) Overview &nbsp; This Adafruit plate makes it easy to use a 16&#215;2 Character LCD. Unfortunately, these LCDs do require quite a few digital pins, 6 to control the LCD and then perhaps another 3 to control the RGB backlight for a total of 9 pins. That&#8217;s nearly all the GPIO available on a Raspberry &hellip; <\/p>\n<p><a class=\"more-link block-button\" href=\"https:\/\/blog.soton.ac.uk\/pi\/modules-available\/adafruit-rgb-lcd-display\/\">Continue reading &raquo;<\/a><\/p>\n","protected":false},"author":84718,"featured_media":0,"parent":8,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-36","page","type-page","status-publish","hentry","nodate"],"_links":{"self":[{"href":"https:\/\/blog.soton.ac.uk\/pi\/wp-json\/wp\/v2\/pages\/36","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.soton.ac.uk\/pi\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blog.soton.ac.uk\/pi\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blog.soton.ac.uk\/pi\/wp-json\/wp\/v2\/users\/84718"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.soton.ac.uk\/pi\/wp-json\/wp\/v2\/comments?post=36"}],"version-history":[{"count":12,"href":"https:\/\/blog.soton.ac.uk\/pi\/wp-json\/wp\/v2\/pages\/36\/revisions"}],"predecessor-version":[{"id":160,"href":"https:\/\/blog.soton.ac.uk\/pi\/wp-json\/wp\/v2\/pages\/36\/revisions\/160"}],"up":[{"embeddable":true,"href":"https:\/\/blog.soton.ac.uk\/pi\/wp-json\/wp\/v2\/pages\/8"}],"wp:attachment":[{"href":"https:\/\/blog.soton.ac.uk\/pi\/wp-json\/wp\/v2\/media?parent=36"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}