lcd display python supplier

Based on those MakePython solutions, Makerfabs can also help to customize those boards with customer’s special requests. Contact sales@makerfabs.com for detailed info and further discussion.

Python is one of the most widely used, simple, and easy-to-learn programming languages around. MicroPython is a lean implementation of the Python 3 programming language that has been pared down to run efficiently on microcontrollers.

This MakePython ESP32 Color LCD is the color LCD version of the MakePython ESP32. The only difference is that this version using a colorful 1.3 inch LCD ST7789, which makes the boards suitable for applications that need a colorful display. Besides, also this version has 2 optional for users: WROOM(NO PSRAM) and WROVER(8MB PSRAM).

The MakePython ESP32 color LCD board is programmed with MicroPython by default, users can begin the MicroPython development as getting them on hand. There"s also the Makerfabs MakePython ESP8266.

lcd display python supplier

The mini LCD screen display supports a resolution of 84*48. By programming in Python, the Raspberry Pi can control the screen to display the CPU and memory usage of your Raspberry Pi. Thus you can check the date easily.

The shield is equipped with a backlight switch, so you can see the contents displayed clear in the darkness, and also turn on/off the backlight anytime as you like. It works with Raspberry Pi Model B/B+, 2 Model B, and 3 Model B.

lcd display python supplier

An online editor for creating customer characters is available online at https://clach04.github.io/lcdchargen/ (source code available from https://github.com/clach04/lcdchargen/tree/python)

lcd display python supplier

In the previous project of the Raspberry Pi Series, I have shown you how to blink an LED using Raspberry Pi and Python Program. Moving forward in the series, in this project, I’ll show you the interfacing 16×2 LCD with Raspberry Pi.

In this project, you can see all the steps for Interfacing a 16×2 LCD with Raspberry Pi like circuit diagram, components, working, Python Program and explanation of the code.

Even though the Raspberry Pi computer is capable of doing many tasks, it doesn’t have a display for implementing it in simple projects. A 16×2 Alphanumeric Character LCD Display is a very important types of display for displaying some basic and vital information.

A 16×2 LCD is one of the most popular display modules among hobbyists, students and even electronics professionals. It supports 16 characters per row and has two such rows. Almost all the 16×2 LCD Display Modules that are available in the market are based on the Hitachi’s HD44780 LCD Controller.

The pin description in the above table shows that a 16×2 LCD has 8 data pins. Using these data pins, we can configure the 16×2 LCD in either 8 – bit mode or 4 – bit mode. I’ll show the circuit diagram for both the modes.

In 8 – bit mode, all the 8 data pins i.e. D0 to D7 are used for transferring data. This type of connection requires more pins on the Raspberry Pi. Hence, we have opted for 4 – bit mode of LCD. The circuit diagram (with Fritzing parts) is shown below.

The following image shows the wiring diagram of the featured circuit of this project i.e. LCD in 4 – bit mode. In this mode, only 4 data pins i.e. D4 to D7 of the LCD are used.

NOTE: In this project, we have used the 4 – bit mode of the 16×2 LCD display. The Python code explained here is also related to this configuration. Slight modifications are needed in the Python Program if the circuit is configured in 8 – bit mode.

The design of the circuit for Interfacing 16×2 LCD with Raspberry Pi is very simple. First, connect pins 1 and 16 of the LCD to GND and pins 2 and 15 to 5V supply.

Then connect a 10KΩ Potentiometer to pin 3 of the LCD, which is the contrast adjust pin. The three control pins of the LCD i.e. RS (Pin 4), RW (Pin 5) and E (Pin 6) are connected to GPIO Pin 7 (Physical Pin 26), GND and GPIO Pin 8 (Physical Pin 24).

Now, the data pins of the LCD. Since we are configuring the LCD in 4 – bit mode, we need only 4 data pins (D4 to D7). D4 of LCD is connected to GPIO25 (Physical Pin 22), D5 to GPIO24 (Physical Pin 18), D6 to GPIO24 (Physical Pin 16) and D7 to GPIO18 (Physical Pin 12).

The working of project for Interfacing 16×2 LCD with Raspberry Pi is very simple. After making the connections as per the circuit diagram, login to your Raspberry Pi using SSH Client like Putty in Windows.

I’ve created a folder named “Python_Progs” on the desktop of the Raspberry Pi. So, I’ll be saving my Python Program for Interfacing 16 x 2 LCD with Raspberry Pi in this folder.

Using “cd” commands in the terminal, change to this directory. After that, open an empty Python file with name “lcdPi.py” using the following command in the terminal.

Now, copy the above code and paste it in the editor. It is important to properly use the Tab characters as they help in grouping the instructions in Python.

Save the file and close the editor. To test the code, type the following command in the terminal. If everything is fine with your connections and Python Program, you should be able to see the text on the 16×2 LCD.

First, I’ve imported the RPi.GPIO Python Package as GPIO (here after called as GPIO Package) and sleep from time package. Then, I have assigned the pin for LCD i.e. RS, E, D4, D5, D6 and D7. The numbering scheme I followed is GPIO or BCM Scheme.

Finally, using some own functions like lcd_init, lcd_string, lcd_display, etc. I’ve transmitted the data to be printed from the Raspberry Pi to the 16×2 LCD Module.

By interfacing 16×2 LCD with Raspberry Pi, we can have a simple display option for our raspberry Pi which can display some basic information like Date, Time, Status of a GPIO Pin, etc.

Many simple and complex application of Raspberry Pi like weather station, temperature control, robotic vehicles, etc. needs this small 16×2 LCD Display.

lcd display python supplier

Raspberry Pi 16×2 LCD I2C Interfacing and Python Programming– I have been using 16×2 LCD for quite a long time in different Arduino and IoT related projects. You know we have two types of the 16×2 LCD, the normal one used more wires and the other one is based on the I2C interface which needs only two wires.

If you have the plain version of this display then this tutorial is not for you. The plain version is not practical anyway  it would use a lot of GPIO Pins and it has a complicated programming requirement.

With this version you need only four pins and the programming model is very simple. Other than the display you will need some wires. This is what I will be using.

The backpack module uses the I-squred-C (or I2C) protocol to communicate with the Raspberry Pi, which uses only two wires: SDA and SCL (data and clock). Please note that the display is a 5 volt device, and it is powered by 5 volts, but due to design of the I2C protocol, and the fact that the Raspberry Pi is the controlling device, it is safe to connect such display to the Raspberry Pi directly.

I suggest using wires of different colors to connect the LCD display. This minimizes the risk of damage due to incorrect connections. For example, I’m using

I use the cobbler connector with a breadboard, but the display can be connected to the GPIO headers directly, you’ll just need to use different wires. 5 volts and ground connections are close to each other here, while the SDA and SCL line are connected on the opposite side.

Before you start using the I2C 16×2 LCD display with Python, you need to make sure that the I2C protocol is enabled on your Raspberry Pi. You can use the sudo raspi-config utility to take care of that. This program is navigated using keyboard arrows, tab and the Enter key. Look for I2C in the interfacing options and enable it. Enabling I2C requires a reboot.

And you can also adjust the contrast using a small Phillips screwdriver. Set it somewhere in the middle. Be careful not to short anything with the screwdriver while you make the adjustment. Looks like my display is ready to go.

The 27 hexadecimal addresses happen to be the most common, but your display’s address may be different. For example, it could be 3f. This will depend on the chip version of the backpack module. As long as the i2cdetect command shows the display is connected, you are good to go.

The easiest way to program this 16×2 I2C LCD display in Python is by using a dedicated library. There are many to choose from. I like things simple, so the library I recommend is rpi_lcd.

This library has the default 27 address hard-coded. If your display has a different address you will need to change it. You need to find the library on your system and the following command should do that for you.

I use the clear function at the end of the program, otherwise the message will stay on the display after the program ends. The two numbers (1 and 2) at the end of the text function indicate which line of the display to use.

This is an opportunity to adjust the contrast, especially if the display does not show anything, if you don’t see the “Hello, Raspberry Pi!” message. The adjustment only affects the letters, not the backlight. The backlight in this model is not adjustable, it’s always on, but you can turn it off by removing the jumper on the backpack.

lcd display python supplier

In this tutorial, we will Control a 16x2 LCD Display using Raspberry Pi. We will connect the LCD to GPIO (General Purpose Input Output) pins of PI to display characters on it. We will write a program in PYTHON to send the appropriate commands to the LCD through GPIO and display the needed characters on its screen. This screen will come in handy to display sensor values, interrupt status and also for displaying time.

There are different types of LCDs in the market. Graphic LCD is more complex than 16x2 LCD. So here we are going for 16x2 LCD display, you can even use 16x1 LCD if you want. 16x2 LCD has 32 characters in total, 16 in 1st line and another 16 in 2nd line. JHD162 is 16x2 LCD Module characters LCD. We have already interfaced 16x2 LCD with 8051, AVR, Arduino etc. You can find all our 16x2 LCD related project by following this link.

There are +5V (Pin 2 or 4) and +3.3V (Pin 1 or 17) power output pins on the board, these are for connecting other modules and sensors. We are going to power the 16*2 LCD through the +5V rail.We can send control signal of +3.3v to LCD but for working of LCD we need to power it by +5V. The LCD will not work with +3.3V.

As shown in the Circuit Diagram, we have Interfaced Raspberry Pi with LCD display by connecting 10 GPIO pins of PI to the 16*2 LCD’s Control and Data Transfer Pins. We have used GPIO Pin 21, 20, 16, 12, 25, 24, 23, and 18 as a BYTE and created ‘PORT’ function to send data to LCD. Here GPIO 21 is LSB (Least Significant Bit) and GPIO18 is MSB (Most Significant Bit).

16x2 LCD Module has 16 pins, which can be divided into five categories, Power Pins, contrast pin, Control Pins, Data pins and Backlight pins. Here is the brief description about them:

6. Once this E pin goes low, the LCD process the received data and shows the corresponding result. So this pin is set to high before sending data and pulled down to ground after sending data.

As said we are going to send the characters one after the other. The characters are given to LCD by ASCII codes (American standard Code for Information Interchange). The table of ASCII codes is shown below. For example, to show a character “@”, we need to send a hexadecimal code “40”. If we give value 0x73 to the LCD it will display “s”. Like this we are going to send the appropriate codes to the LCD to display the string “CIRCUITDIGEST”.

lcd display python supplier

If you plan on using an LCD with your Raspberry Pi, there’s a good chance you’ll need to program it in Python at some point. Python is probably the most popular programming language for coding on the Raspberry Pi, and many of the projects and examples you’ll find are written in Python.

In this tutorial, I’ll show you how to connect your LCD and program it in Python, using the RPLCD library. I’ll start with showing you how to connect it in either 8 bit mode or 4 bit mode. Then I’ll explain how to install the library, and provide examples for printing and positioning text, clearing the screen, and controlling the cursor. I’ll also give you examples for scrolling text, creating custom characters, printing data from a sensor, and displaying the date, time, and IP address of your Pi.

You can also connect the LCD via I2C, which uses only two wires, but it requires some extra hardware. Check out our article, How to Setup an I2C LCD on the Raspberry Pi to see how.

There are two ways to connect the LCD to your Raspberry Pi – in 4 bit mode or 8 bit mode. 4 bit mode uses 6 GPIO pins, while 8 bit mode uses 10. Since it uses up less pins, 4 bit mode is the most common method, but I’ll explain how to set up and program the LCD both ways.

Each character and command is sent to the LCD as a byte (8 bits) of data. In 8 bit mode, the byte is sent all at once through 8 data wires, one bit per wire. In 4 bit mode, the byte is split into two sets of 4 bits – the upper bits and lower bits, which are sent one after the other over 4 data wires.

Theoretically, 8 bit mode transfers data about twice as fast as 4 bit mode, since the entire byte is sent all at once. However, the LCD driver takes a relatively long time to process the data, so no matter which mode is being used, we don’t really notice a difference in data transfer speed between 8 bit and 4 bit modes.

If this is your first time writing and running a Python program, you might want to read How to Write and Run a Python Program on the Raspberry Pi, which will explain everything you need to know to run the examples below.

The RPLCD library can be installed from the Python Package Index, or PIP. It might already be installed on your Pi, but if not, enter this at the command prompt to install it:

The example programs below use the Raspberry Pi’s physical pin numbers, not the BCM or GPIO numbers. I’m assuming you have your LCD connected the way it is in the diagrams above, but I’ll show you how to change the pin connections if you need to.

Let’s start with a simple program that will display “Hello world!” on the LCD. If you have a different sized LCD than the 16×2 I’m using (like a 20×4), change the number of columns and rows in line 2 of the code. cols= sets the number of columns, and rows= sets the number of rows. You can also change the pins used for the LCD’s RS, E, and data pins. The data pins are set as pins_data=[D0, D1, D2, D3, D4, D5, D6, D7].

The text can be positioned anywhere on the screen using lcd.cursor_pos = (ROW, COLUMN). The rows are numbered starting from zero, so the top row is row 0, and the bottom row is row 1. Similarly, the columns are numbered starting at zero, so for a 16×2 LCD the columns are numbered 0 to 15. For example, the code below places “Hello world!” starting at the bottom row, fourth column:

The RPLCD library provides several functions for controlling the cursor. You can have a block cursor, an underline cursor, or a blinking cursor. Use the following functions to set the cursor:

Text will automatically wrap to the next line if the length of the text is greater than the column length of your LCD. You can also control where the text string breaks to the next line by inserting \n\r where you want the break to occur. The code below will print “Hello” to the top row, and “world!” to the bottom row.

This program will print the IP address of your ethernet connection to the LCD. To print the IP of your WiFi connection, just change eth0 in line 19 to wlan0:

Each character on the LCD is an array of 5×8 of pixels. You can create any pattern or character you can think of, and display it on the screen as a custom character. Check out this website for an interactive tool that creates the bit array used to define custom characters.

First we define the character in lines 4 to 12 of the code below. Then we use the function lcd.create_char(0-7, NAME) to store the character in the LCD’s CGRAM memory. Up to 8 (0-7) characters can be stored at a time. To print the custom character, we use lcd.write_string(unichr(0)), where the number in unichr() is the memory location (0-7) defined in lcd.create_char().

To demonstrate how to print data from a sensor, here’s a program that displays the temperature from a DS18B20 Digital Temperature Sensor. There is some set up to do before you can get this to work on the Raspberry Pi, so check out our tutorial on the DS18B20 to see how.

In general, you take the input variable from your sensor and convert it to an integer to perform any calculations. Then convert the result to a string, and output the string to the display using lcd.write_string(sensor_data()):

Well, that about covers most of what you’ll need to get started programming your LCD with Python. Try combining the programs to get some interesting effects. You can display data from multiple sensors by printing and clearing the screen or positioning the text. You can also make fun animations by scrolling custom characters.

lcd display python supplier

Hey everyone, in this tutorial we are going to interface a Liquid Crystal Display (LCD) module with the Raspberry Pi Pico using Micropython. By the end of this tutorial, you will be able to display strings, characters on the LCD using Micropython. Before beginning this tutorial, I"m presuming that you"ve already followed our tutorial series on Raspberry Pi Pico. Previously we have worked with an OLED display and we have seen the I2C and ADC on the Raspberry Pi Pico. Now, let’s see how to interface an LCD display module with the pico board.

The 16x2 LCD gets its name from the fact that it contains 16 columns and 2 rows. As a result, it will contain a total of (16x2=32) 32 characters, with each character consisting of 5x8 Pixel Dots. The image below depicts a single character with all of its pixels.

Each character has a size of (5x8=40) 40 pixels, giving us a total of (32x40) 1280 pixels for 32 characters. Additionally, the LCD instructions should be told where the pixels are located. As a result, controlling everything using a microcontroller will be challenging. So, an interface IC, such as the HD44780, is used on the backside of the LCD Module. More information is available in the HD44780 Datasheet.

This IC"s job is to take commands and data from the MCU and process them so that relevant information may be shown on the LCD screen. Without a backlight, the LCD"s working voltage ranges from 4.7 to 5.3 volts and its current usage is 1mA. It is capable of working in both 8-bit and 4-bit modes. These LCDs come with a green or blue backlight and may also show any characters created by the user.

The LCD display will have 16 Pins. ThePinout and Pin Description of the 16x2 LCD Module is mentioned in the table below. You can refer to this article on 16x2 LCD Display Module on our website for more details about the LCD pinouts.

The following circuit diagram is representing the connection of the LCD to the Raspberry Pi Pico. I have used a potentiometer to control the brightness of the LCD display. The 4-bit data pins (i.e. D4 to D7) are connected to the GPIOs 18,19,20,21 respectively. The Rs pin of the LCD is connected to the GPIO 16 and the E pin is connected to the GPIO 17. The output of the potentiometer is connected to the V0 pin of the LCD and the VBUS pin is connected to the input terminal of the potentiometer. This VBUS pin of the pico is used to power the LCD via VDD pin of the LCD. Pin number 15 of the LCD is connected to the VDD pin of the LCD to provide the power supply of 5V and Pin number 16 of the LCD is connected to the Ground pin followed by the RW pin of the LCD.

To program the LCD with Raspberry Pi Pico using Micropython, you need to download the respective library and code files from our GITHUB repository of the Raspberry Pi Pico Tutorial Series. When you open the “codes”, you will get two python files named “lcd_pico.py” and “main.py”. The “lcd_pico” can be used as a library to program the LCD display with Raspberry Pi Pico using Micropython. In the “main.py” file I have used some functions from the “lcd_pico.py” file to display some strings on the LCD. Let’s discuss both python files one by one.

In the “lcd_pico.py” file, we have imported two libraries “machine.py” and the “utime.py”. The machine library contains the built-in functions to define the Pins, GPIOs, etc. The “utime” library is used to provide the delay in the code. Then I have defined the GPIO pins for the 4-bit data pins of the LCD and the RS and E pin of the LCD. The “machine.Pin(16,machine.Pin.OUT)” is used to set the GPIO21 as OUTPUT and assign this in the “rs” variable. Similarly, the GPIOs 17 to 21 are set as OUTPUT pins and assigned to the “e”, “d4”, “d5”, “d6”, and “d7” variables respectively.

The “setCursor(line,pos)” function below is used to set the position of the cursor. We need to pass two parameters “line” and “pos”. In my case, I am using the 16x2 LCD which has 2 lines to set the cursor. And the “pos” is used to set the position where we want to print the data.

TheclearScreen() function is used to clear the display screen and the setupLCD() function is used to initialized the LCD. We need to use the setupLCD() function at the starting of our main code. The displayString() is used to display any String data. This function takes three parameters that are “row”, “col” and the “input_string”. The “row” and “col” are used to set the cursor position and the “input_string” is used to pass the string that needs to be print on the LCD.

In the main.py file, I have imported the “lcd_pico” library and then I have called the “setupLCD()” function. Then I used the “displayString()” function to print the following strings. In this function, I have passed the “row” and “col” to set the cursor position and then I have passed the strings to be displayed on the LCD. The longDelay() function is used to provide the delay in microseconds.

In the while loop below I have used the displayString() to display the “CIRCUIT DIGEST” with 1.5 seconds of interval. The clearScreen() is used to clear the display screen in every 1.5 Seconds.

Now, in the Thonny IDE, open the “main.py” and “lcd_pico.py” files. To begin, save the “lcd_pico.py” file on the Pico board by pressing the “ctrl+shift+s” keys on your keyboard. Before saving the files, make sure your Pico board is connected to your laptop. When you save the code, a popup window will appear, as shown in the image below. You must first select the Raspberry Pi Pico, then name the file “lcd_pico.py”andsave it. Then repeat the process for the“main.py” file. This procedure enables you to run the program when the Pico is turned on.

When you upload and run the code on the pico board, you will see the output similar to the images below. The first image is showing the “WELCOME” string in the first row of the LCD and “TO” string in the second row of the LCD. Then after 4 seconds of delay, it is displaying the “CIRCUIT” string in the 1st line of the LCD and “DIGEST” string in the 2nd line of the LCD.

lcd display python supplier

This tutorial is to fulfill the requirement of sending messages to the display from a web application. We learned how to create a webserver using python using the Flask framework in the previous article. Interfacing of LCD to Raspberry Pi is well discussed in AdaFruit website. Here is a simple yet interesting example of how to create a new web application that will interact with the Raspberry Pi and display the characters given by the Web application in the LCD interfaced with it.

We will make a straightforward web application with a frame that permit a client to send a message to the Raspberry Pi utilizing Flask in a web browser. This will permit us to control the Raspberry Pi from a PC, tablet or smart phone. At the point when the form is submitted, it will send the message to the LCD by means of the Raspberry Pi’s GPIO ports. All the code, including the web application, is in Python and HTML.

Here we’ll be utilizing the modified AdaFruit_CharLCD.py library according to our connections in the circuit, so make sure you have everything up-and-running as per the AdaFruit tutorial except the connections. So we have to set up the folder structure that we need.

lcd display python supplier

The 5110 LCD is ideal for battery projects as it consumes little power. The resolution 84x48 is restrictive though. If you are buying a few of them, get them from the same provider. I have a few with slightly different shades of backlight. Just enough to be noticible and annoying.

You can get huge 7 segment displays, like 5x10cm per digit. A few of these would be ideal for an odometer. Low power, bright, no need for backlight, rugged. Controlled with either a max7219 or a ht16k33.

You can get 128x64 graphic LCDs, which are similar physical dimensions to a 20x4 character LCD. The yellow/black versions would give better readability in full sun than blue/white LCDs. This would give you a large area for custom graphics. The pixels are large enough to be readable from a distance. The pixel layout is similar to the OLED and the Nokia, so if you trial each display, you can share code.

The character LCDs based on hd44780 come in a few sizes. 8x8, 16x1, 16x2, 16x4, 20x2 and 20x4. That is character sizes. Each char is 5x8, and you can only have 8 custom chars in ram, so rather limited. Great for lots of ascii text.

The graphic LCDs, char LCDs and TFTs differ from the OLEDs as the pixels block light rather than emit. You need a backlight to be able to read them in most cases.

Which one is best for a bike HUD? Well... it depends on a few things. What information you want to display. How readable it needs to be. How rugged it needs to be. How fast it needs to refresh. How many MCU pins it needs. Your budget. Reliability - so you are safe if it crashes/reboots. Are there any laws / compliance you need to follow?

lcd display python supplier

Depending on your display stand, you might find that the LCD display defaults to being upside-down. You can fix this by rotating it with /boot/config.txt.

At the moment you can’t use HDMI and the LCD together in the X desktop, but you can send the output of certain applications to one screen or the other.

lcd display python supplier

16x2 means 16 characters and 2 lines. This LCD is very common and is now specially designed to interface with microcontrollers and other things. The being barebone uses 16 pins but the I2c module gives them this power two utilizing two lines for data and clock while two for power. I also have one and I wanted to interface it with my VisionFive board which is Single Board Computer specially designed to run Linux. So Let"s dig into it.

It"s a really simple diagram. All you have to do is to connect the SDA of LCD to the SDA of VisionFive which is at GPIO48 or physically at pin number 3. And SCL of LCD to the SCL of VisionFive which is at Pin number 5. Connect VCC to the 5v line of VisionFive and ground to the ground.

We are going to need a Library for I2C LCD that I luckily found at Recantha. This library allows us to Interface LCD with Python. It was designed to interface this LCD with raspberry pi but we can use it too. I updated this library a little bit to which I"ll provide the link.

Anyways, now you can run the example script that is provided with this library on my Github page. You can run the script in two ways, either by command line or by opening the file with IDLE and then running it using the python shell.

lcd display python supplier

In this tutorial Tony Goodhew explains how to use the basic graphics procedures which are included in the display driver, and for the ambitious makers out there he also provides examples for advanced shapes and graphics!

All the other graphical and text objects we would like to display can be built from this single pixel instruction; such as lines, circles, rectangles, triangles and text strings at different sizes.

This is all carried out with code. Display manufacturers usually supply some of these procedures/methods but leave the rest up to the end user to construct.

At the top of our driver program we will always import a minimal set of libraries using this block at the top of our MicroPython script (we add even more later when we want to do advanced programs):

The third line here imports the Framebuffer library which includes several very useful routines to draw objects on the display. The garbage collection library, gc, has also been imported so that we can check how much memory is available.

The following methods draw shapes (such as those above) onto the FrameBuffer. They only become visible to the user once the lcd.show() instruction is executed.

Each program contains the screen driver code, sets up the buttons/joystick (if applicable), sets the width and height variables, loads the essential libraries, defines the colour (R, G, B) and clear (c) procedures, then displays some colour checking text like this:

Using lcd.fill_rect, fill the whole screen green and then fill the middle of the screen black, leaving a 10 pixel border. Put red 10-pixel squares in each corner.

Draw a dark grey rectangle in the centre of the screen. Draw 500 white pixels inside the square, none touching the edge. (Random was explained in the previous display tutorial.)

This is routine is very complicated. It splits the original triangle into two with a horizontal line and then fills them in. If you uncomment all the # lcd.show() lines and sleep instructions it will slow right down and you can see it working (unfortunately, the 2” display needs such a large buffer that there is not enough memory for the filled triangles code):

For the imports we added the math library as this is needed for Sin and Cos in graph plotting. The random library has also been imported, for the randomly generated triangles. These are followed by the basic LCD board setup we covered earlier.

In the centre of the screen display a ‘bull’s eye’ circular target with a ‘gold’ centre, 4 other colours and scores 10, 8, 6, 4 and 2 written in the appropriate positions.

You may have noticed that on some screens the text is very small and difficult to read. In a following tutorial will add an extra font, with more characters, which we can display in different sizes.

This article was written by Tony Goodhew. Tony is a retired teacher of computing who starting writing code back in 1968 when it was called programming - he started with FORTRAN IV on an IBM 1130! An active Raspberry Pi community member, his main interests now are coding in MicroPython, travelling and photography.