In this tutorial, we’ll connect a Raspberry Pi Pico to a 7-segment display. The cheapest display unit is a seven-segment display. You can show temperature, counter value, and other information by stacking a few of these segments together. The 7-segment display device connects to the GPIO of the PI. It will also be regulated to display digits accordingly. After that, we’ll write a PYTHON program for a seven-segment show that counts from 0 to 9 and then resets to zero.

You can use a seven-segment display in a variety of applications, typically to display a single number. Further, these devices have basic internal wiring diagrams that map LEDs to pins one by one.

Seven section displays are a well-known method of showing numbers and a short series of letters on a computer screen. They’ve been around for as long as I’ve been interested in electronics. But due to the large number of LEDs involved it is a pain to wire them up.

Bill of materials

7segment displaySeven LEDs are set in a rectangular pattern on the 7-segment display. Each of the seven LEDs is referred to as a section and when illuminated, it forms part of a numerical digit (both decimal and hexadecimal) that would be shown. When two or more 7-segment displays are wired together to display numbers greater than ten, an additional 8th LED is often used within the same set to allow the indication of a decimal point, (DP).
Raspberry Pi Pico
The Raspberry Pi Pico, unlike previous Pis, is a microcontroller board similar to Arduino. The Raspberry Pi Pico’s main selling points are its $4 price tag and the latest RP2040 chip, which offers plenty of power for embedded projects. It allows people of any age or skill to learn coding and electronics.
BreadboardA breadboard is a temporary solderless structure for prototyping electronics and testing circuit designs. Most electronic circuit components can be connected by slipping their leads or terminals into the holes and connecting them with wires as required. Metal bars run under the breadboard, connecting the holes on the top of the board.

As seen in the diagram, the metal strips are arranged as follows. The holes in the top and bottom rows are horizontally connected and divided in the centre, while the holes in the centre are connected vertically. Take note of the relations between the selected row holes and the holes in the selected column. A node is a set of connected holes. To bind the chosen row and column, a cable must run from any hole in the row to any hole in the column.
USB cable
The Universal Serial Bus (USB) is an industry standard that specifies standards for cables and connections, as well as protocols for connection, connectivity, and power supply (interfacing) between machines, peripherals, and other computers.
Female to female jumper wiresThey are just connecting wires. There are three types of jumper wires.

1. Male to male
2. Male to female
3. Female to female

Male to female jumper wires for attaching regular 2.54 Mm header pins as well as eliminate connectors on various construction boards.
As in our project, we will use Female to female jumper wires as 7segment display as pins so we need to solder raspberry pi pico for joining female to female jumper wires
MicroPythonMicroPython is a bare-metal Python compiler and runtime in one package. You’ll get an interactive prompt (the REPL) that lets you run and import scripts from the built-in filesystem, as well as run commands right away. The REPL provides features such as history, tab completion, auto-indent, and paste mode to improve the user interface.

MicroPython seeks to be as close to standard Python (also known as CPython) as possible since anyone who knows Python already knows MicroPython. On the other hand, the more MicroPython you practise, the better at Python you can get.
In addition to incorporating a variety of main Python libraries, MicroPython offers modules such as “computer” for accessing low-level hardware.

7 Segment display

The 4 Digit 7 Segment Display is an essential electronic display similar to the Single 7 Segment Display, but with four digits and can represent four characters at once. It has dot LEDs as well, albeit in various configurations (single for each digit, central colon, etc).

These displays are very common, but they are still one of the most powerful in embedded applications. This display includes only 8 LEDs inside. These 8 LEDs are divided into segments that are labelled a,b,c,d,e,f,g,DP. One end of each of these 8 section LEDs’ pins has been pulled out of the module, and the other ends have been attached and pulled out as the common pin.

So, to make an LED with a specific segment shine, we need to power the typical pin and the segment pin. We can power more than one section to display the numeric number 0-9 and a few Alphabets. You can use the DP pin to show a decimal point. 7-segment screens, such as those used on old digital alarm clocks, can be useful in Raspberry Pi designs, including those designed with the Raspberry Pi Pico.

You can use a 7-segment monitor to keep track of time, reveal sensor data such as temperature or distance, or keep score in a game. You can also see some letters.

Controller board:

Controller boards that use an I2C link with just four pins control the 7 segment display. These controller boards operates by a TM1637 controller board. We’ll show you how to attach a Raspberry Pi Pico to one of these TM1637-powered 7-segment displays below.

Pins 12, 9, 8, and 6 drive-in what digit location to display until A and DP pins are set to 1 (HIGH) to display the correct number. You must set these four pins to 1 (HIGH) for cathode elements. Then only the digit will start. Similarly, for anode components, you should set these pins to 0 (LOW). Exceptions include the digit you want to power on.



  F |   | B   *

     -G-      H (on 2nd segment)

  E |   | C   *



I2C Address selection:

The HT16K33 device’s default I2C address is 0x70. Due to three solder points on the PCB that allows for the specification of seven additional addresses, you can use multiple modules at the same time. Address set: 0x70 to 0x77.

What are different  types of 7-segment Display?

There are two types of a 7-segment displays Common Cathode and Common Anode

Common Cathode (CC): The positive terminals (Anodes) of all eight LEDs are connected in this circuit, which is referred to as COM. And all of the negative thermals are left to their own devices. The CC display stands for generic cathode display. The typical pin on the 7-segment display is attached to all eight Cathode pins of the LEDs in this configuration. To make this form of seven-segment display function, link the Com pin to the Ground pin and control the remaining pins with Vcc (+5V).

Common Anode (CA): – The Negative terminals (cathode) of all 8 LEDs are connected in this circuit, which is referred to as COM (see diagram below). Many of the positive terminals are unaffected. The CA display stands for popular anode display. The typical pin on the 7-segment display is attached to all eight Anode pins of the LEDs in this configuration. Switching on this seven-segment shows links the Com pin to Vcc (+5V typically) and ground the appropriate segment pin.

Note – When using a 4-digit 7-segment display, keep in mind that the standard anode pin connects to the power source, while the standard cathode pin connects to GND. This guide is based on cathode one; however, the nut anode works with the same code by inverting the digit selection logic. When multiplexing multiple cells, these CC and CA seven segment displays come in handy.

Technical features of 7segment display1. Common Cathode (CC) and Common Anode (CA) are the two modes available.
2. It is available in a range of sizes, including 9.14mm, 14.20mm, 20.40mm, 38.10mm, 57.0mm, and 100mm (the most common version is 14.20mm).
3. White, Blue, Red, Yellow, and Green are available colors (Res is commonly used).
4. Low-voltage service.
5. Compared to traditional LCD screens, this one has a better, lighter, and more extensive panel
6. 30mA per section is the composition of the current.
7. 70mA is the peak current.
Applications of 7segment display1. They are used in applications where larger font size is available
2. Since it is not based on a microcontroller, it is commonly used in small circuit ventures.
3. Or used in conjunction with four segments, the measurement/sensor value is displayed using four characters.
4. Since it has bright lighting, it’s ideal for use in low-light or dark environments.

How to Select a 7segment display:

There are several options for a 7-segment monitor in the Features section. It includes a variety of ranges, sizes and colours. Usually, the 14.20mm with Red colour display is the most widely used one. But if you want to make your project different, you can use other color displays as well.

Often keep in mind that the amount of current used by the show can vary depending on the size and colour. As it consumes less current than other colours, everyone prefers the red one.

There is one more critical parameter on which you should focus before purchasing this module. You can use a Common Anode or a Common Cathode display.

7-segment display’s Circuit Diagram with Pico

  • Set the VCC pin to 3V3 (physical pin 36, the fifth on the right side).
  • Then attach the GND pin to GND (physical pin 34, the third on the right side).
  • Connect the CLK pin to GP16 (last pin on the right side).
  • Pico’s DIO pin connects to GP17 (next-to-last pin on the right side).

The CLK and DIO pins connects to any two GPIO pins on the Pico that support I2C SCL and SDA, respectively. then the GND pin connects to any of the Pico’s eight GND pins.

D1 Mini4digit display
3V3 (or 5V)VCC

Software setup Steps for 7segment display in MicroPython:

  1. We’ll use the TM1637 MicroPython library to build a script that demonstrates a range of view possibilities, which you can use in your own projects later.
  2. After that you can download the file from the GitHub project. Note that you don’t need the other extra files.
  3. You should copy the to the root directory of your Pico. Since the Pico with MicroPython does not appear as a drive letter, the simplest method is to open in Thonny or the IDE of your choosing and save it from there.
  4. In Thonny or your favourite MicroPython IDE, generate a new MicroPython script.
  5. You can then import libraries that you need.
import tm1637
from machine import pin
from utime import sleep

We’ll use the utime library to add a one-second “sleep” delay for each feature so you can keep an eye on them on the screen.

6. Build a new instance of the tm1637.TM1637 object called “display” and set the CLK & DIO pin numbers as parameters.

display = tm1637 . TM1637(clk=pin(16), dio=pin(17))

7. To view any four characters, use the “show” tool. These may be letters or numbers, but often letters, such as W, may be clumsy. It will show only the first four characters if you type more than four. Make sure the parameter string is enclosed in quotes.“pico”)

8. Using “show” with four blank spaces to clear the screen (assuming you have four digits on your screen).“    “)


It’s important to remember that if you don’t blank the screen, it will stay on until your software has completed. When adjusting the window, you don’t have to clear it, so if you use another show command with a smaller number of characters than the limit, any characters that aren’t replaced will remain on the screen. The screen will read 20lo if you do show(“halo”) and then show(“20”).
9. To display an integer, use the "digit" procedure. But don't surround the parameter with quotations. You may display a negative or positive number, but if it's a negative number, the minus sign would take up one letter. If you input a number that is greater than the number of digits available (for example, 12345 on a four-digit display), the computer will display “9999” or “-999” for negative numbers.

To display a time with the colour visible, use the “numbers” tool. Enter two two-digit numbers as parameters, and the colon will appear between them if your screen has one. The time will be shown as 12: -59 in this case.

10. Given that the “display” method can be used to display numbers or letters, you may be wondering why you’d like to use the number method instead. One explanation is that you won’t have to translate integers to strings, and another is that the screen will only show the number of digits needed, so you won’t have to enter blank spaces to match the number to the right.


11. You can change the brightness using the light process. The parameter may be any number between 0 and 7, with 0 being the lowest and 7 being the highest.

#adjust the brightness to make it lower

12. To view scrolling text, use the “scroll” tool. To control the speed of the scroll, enter a string (in quotes) as the first parameter, followed by “delay=” and a number of milliseconds. If you don’t specify a delay, it will default to 250 milliseconds.

dispaly.scroll(“hello world 123”, delay=200)

13. To display a temperature in Celsius, use the “temperature” process. After your numbers, this form adds the degree symbol and the letter C. The temperature is entered as a one- or two-digit integer, and negative temperatures are allowed but must be one digit.


14. Blank the screen once more so that it does not remain illuminated until the software has finished.“    “)


import tm1637
from machine import pin
from utime import sleep
dispaly = tm1637 . TM1637(clk=pin(16), dio=pin(17))“pico”)
sleep(1)“    “)
#adjust the brightness to make it lower
dispaly.scroll(“hello world 123”, delay=200)
sleep(1)“    “)

Enjoy seeing the numbers add up after you’ve uploaded your software by the USB cable to your Raspberry Pi Pico.

After interfacing the 7 segment display, it can be used for other applications as well. For more details, check out the video given above.

0 0 votes
Article Rating
Next articleHow to add a reset button to your Raspberry Pi Pico
Notify of
Inline Feedbacks
View all comments