Reader small image

You're reading from  Raspberry Pi Pico DIY Workshop

Product typeBook
Published inMay 2022
PublisherPackt
ISBN-139781801814812
Edition1st Edition
Right arrow
Authors (2):
Sai Yamanoor
Sai Yamanoor
author image
Sai Yamanoor

Sai Yamanoor is an embedded systems engineer working for a private startup school in the San Francisco Bay Area, where he builds devices that help students achieve their full potential. He completed his undergraduate work in mechatronics engineering from Sri Krishna College of Engineering and Technology, Coimbatore, India and his graduate studies in mechanical engineering at Carnegie Mellon University, Pittsburgh PA. His interests, deeply rooted in DIY and open software and hardware cultures, include developing gadgets and apps that improve the quality of life, Internet of Things, crowdfunding, education, and new technologies. In his spare time, he plays with various devices and architectures, such as the Raspberry Pi, Arduino, Galileo, Android devices and others. Sai has earlier published a book titled Raspberry Pi Mechatronics Projects.
Read more about Sai Yamanoor

Srihari Yamanoor
Srihari Yamanoor
author image
Srihari Yamanoor

Srihari Yamanoor is a mechanical engineer, working on medical devices, sustainability, and robotics in the San Francisco Bay Area. He completed his undergraduate studies in mechanical engineering from PSG College of Technology, Coimbatore, India and graduate studies in mechanical engineering at Stanford University. He is certified in SolidWorks, simulation, sustainable design, PDM as well as in quality and reliability engineering and auditing. His has a wide range of interests, from DIY, crowdfunding, AI, travelling, photography to gardening and ecology.
Read more about Srihari Yamanoor

View More author details
Right arrow

Chapter 6: Designing a Giant Seven-Segment Display

In this chapter, we will have fun with some retro-style displays. We will build a giant display driven by the Pico. It is a fun experience to build visual aids involving LEDs and seven-segment displays. By the end of this chapter, you should be able to build something like the display shown in the following figure, where we have a seven-segment display inside a shadow box:

Figure 6.1 – Giant seven-segment display

In this chapter, we will discuss building such visual aids. We will also discuss options to build displays of different sizes and applications. The topics discussed in this chapter include the following:

  • Inspiration for the project
  • Installing the required libraries
  • Selecting a seven-segment display
  • Wiring up the giant seven-segment display
  • Writing the drivers for the giant seven-segment display
  • Using the display
  • Putting it all together

Technical requirements

The following hardware are recommended for this chapter:

The code samples for this chapter are available from https://github.com/PacktPublishing/Raspberry-Pi-Pico-DIY-Workshop/tree/main/chapter_06.

Code in Action videos for this chapter can be viewed at https://bit.ly/3MN0lBO.

Seven-Segment Digits

For this project, we...

Inspiration for the project

We have a general interest in building visual aids for improving quality of life. These visual aids can be used to transmit calculated data and serve to inform users on progress toward goals, suggest how much progress is remaining, or for other purposes. We have used this in healthcare settings previously. For instance, people with chronic health conditions, or a propensity to develop chronic conditions such as diabetes or obesity, can greatly benefit from such displays. In the past, we have developed solutions that recorded daily step counts accomplished, as well as the opposite, the remainder of the steps required to meet daily goals, which, when displayed through these visual aids, and when displayed prominently, can be unmissable.

Using the Pico, such visual aids can be developed for similar applications as well as for uses far and wide. For instance, visual aids can be used to track scores between teams competing as motivation to accomplish health...

Installing the required libraries

In this section, we will install the libraries required for the project. These include the drivers for the wireless pack and the seven-segment display.

CircuitPython Installation

We are assuming that you have installed CircuitPython on your Pico. If you are not familiar with the installation process, we recommend following the installation process from Chapter 1, Getting Started with the Raspberry Pi Pico.

The libraries are all part of the Adafruit CircuitPython bundle. The latest bundle could be downloaded as a ZIP file from https://circuitpython.org/libraries. We used the bundle version meant for CircuitPython 6.x.x.

After downloading the ZIP file, extract its contents so that you can copy the libraries we need for the project.

Wireless pack

We need the adafruit_esp32spi library for the wireless pack. Copy over the folder (with the same name) to the lib folder of your Pico. We will also need the adafruit_reqests.mpy binary from...

Selecting a seven-segment display

We chose a 6.5" seven-segment display for this chapter. We chose it because of its giant size but each digit needs a separate driver. The following figure shows a seven-segment digit with a driver soldered on its back:

Figure 6.4 – 6.5" seven-segment digit with a driver on the back

The total cost of a single digit comes to around USD 30. It can get quite expensive and so we wanted to suggest some alternatives that might suit your budget. We found a smaller display on eBay for USD 4. It is available from here: https://ebay.to/3nKtd4F.

You should be able to use the drivers written for the giant seven-segment display to drive this tiny display (shown in the following figure). The only disadvantage of this display is that it is very small and the numbers cannot be seen from a distance:

Figure 6.5 – Small seven-segment display

If you are looking for a slightly bigger display at...

Wiring up the giant seven-segment display

In this section, we will wire up the display to the Raspberry Pi Pico. We used the Pico Omnibus – Dual Expander from Pimoroni. This enables interfacing the wireless pack and wiring up the seven-segment display. The steps to interface the display are as follows:

  1. Assemble the individual seven-segment digits. The driver needs to be soldered onto the back of each digit. Soldering the driver is a very simple step and we followed the instructions available from SparkFun (link: https://bit.ly/3hLUobk).
  2. Then, we connected the seven-segment driver to the following pins of the Pico, as shown in the following figure:
    • Latch | GP17
    • Clock | GP18
    • Serial | GP19
    • 5V | VBUS
    • 12V | External power supply

The following figure shows the Fritzing schematic for the connections between the seven-segment driver and the Raspberry Pi Pico:

Figure 6.7 – Fritzing schematic to interface the Pico to the seven-segment driver

...

Writing the drivers for the giant seven-segment display

In the previous section, we wired up the display. Now, we need to write the drivers to test the display. We ported the C++ code provided by SparkFun to CircuitPython:

  1. The first step is to import all the required modules for the driver:
    import board
    import busio
    import time
    from digitalio import DigitalInOut, Direction, Pull
  2. We declare the latch, clock, and data pins and set them up as output pins. We also set them all to low:
    latch = DigitalInOut(board.GP22)
    clock = DigitalInOut(board.GP26)
    data = DigitalInOut(board.GP27)
    latch.direction = Direction.OUTPUT
    clock.direction = Direction.OUTPUT
    data.direction = Direction.OUTPUT
    latch.value = False
    clock.value = False
    data.value = False
  3. The post_number function is used to display a number, decimal place, and so on. This is accomplished by turning on the corresponding segments of the digit. For example, in order to display the number 1, we need to turn on the B and C segments...

Using the display

In this section, we will discuss driving the displays in two ways: with a simple web server running on the Pico and via a serial port.

Let's get started!

Simple web server

In this example, we will host a simple web server on the Pico so that we can update the display using a browser from any device on a local network. This example is based on the esp32spi_wsgiserver example made available from Adafruit (link: https://bit.ly/3itHrmY). We made some simple modifications to the code sample to adapt it to our example. The modified code sample is available for download from this chapter's repository as code_server.py (link: https://bit.ly/3hqWA7X).

The changes made to the server example include the following:

  • Importing the seven_segment driver so that we can update the display when there is a request:
    import seven_segment
  • We updated the GPIO pin numbers to drive the ESP32 wireless pack:
    # If you have an externally connected ESP32:
    esp32_cs...

Putting it all together

When you are done testing the display, it is time to assemble it. We initially planned the layout of the entire display on a sheet of plywood, as shown in Figure 6.16:

Figure 6.16 – Planning the layout of the seven-segment display

This enabled us to determine the dimensions of the shadow box needed for the project. We purchased a shadow box and assembled the digits on the back panel of the shadow box, as shown in Figure 6.17:

Figure 6.17 – Seven-segment digits assembled onto the back panel

Since the dual expander board does not come with a mounting hole, we used double-sided tape to stick it to the back side of the shadow box. You should have something like that shown in Figure 6.18:

Figure 6.18 – Giant seven-segment display

The shadow box made it easy to transport for Maker Faire exhibits. We usually power it using a 12 V DC adapter. When an internet connection is...

Summary

In this chapter, we discussed building a giant seven-segment display. We discussed the drivers meant for driving the display. We also discussed planning a layout and assembling the display into a shadow box. This was followed by a review of how to use the display by connecting it to the internet and displaying numbers.

In the next chapter, we will discuss building an exhibit for tracking air quality.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Raspberry Pi Pico DIY Workshop
Published in: May 2022Publisher: PacktISBN-13: 9781801814812
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (2)

author image
Sai Yamanoor

Sai Yamanoor is an embedded systems engineer working for a private startup school in the San Francisco Bay Area, where he builds devices that help students achieve their full potential. He completed his undergraduate work in mechatronics engineering from Sri Krishna College of Engineering and Technology, Coimbatore, India and his graduate studies in mechanical engineering at Carnegie Mellon University, Pittsburgh PA. His interests, deeply rooted in DIY and open software and hardware cultures, include developing gadgets and apps that improve the quality of life, Internet of Things, crowdfunding, education, and new technologies. In his spare time, he plays with various devices and architectures, such as the Raspberry Pi, Arduino, Galileo, Android devices and others. Sai has earlier published a book titled Raspberry Pi Mechatronics Projects.
Read more about Sai Yamanoor

author image
Srihari Yamanoor

Srihari Yamanoor is a mechanical engineer, working on medical devices, sustainability, and robotics in the San Francisco Bay Area. He completed his undergraduate studies in mechanical engineering from PSG College of Technology, Coimbatore, India and graduate studies in mechanical engineering at Stanford University. He is certified in SolidWorks, simulation, sustainable design, PDM as well as in quality and reliability engineering and auditing. His has a wide range of interests, from DIY, crowdfunding, AI, travelling, photography to gardening and ecology.
Read more about Srihari Yamanoor