Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to display digital countdown with 1-digit tube in raspberry pie Python

2025-01-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

Raspberry pie Python how to use a digital tube to display digital countdown, this article introduces the corresponding analysis and solution in detail, hoping to help more friends who want to solve this problem to find a more simple and feasible way.

Display digital countdown with 1-bit digital tube

Overview

In the last article, we learned to use PWM to control the brightness of LED. This time we learned to use a digital tube to display a single-digit countdown.

Through this lesson, we can learn:

Display principle of 1-bit digital tube

Required hardware

Raspberry pie x1

Bread board x1

DuPont line x9

1-bit digital tube x1

Name interpretation

Digital tube

Digital tube is also known as LED digital tube. People in different industries have different names for digital tube. In fact, they are all the same products.

According to the number of segments, the digital tube can be divided into seven-segment digital tube and eight-segment digital tube, and the eight-segment digital tube has one more light-emitting diode unit than the seven-segment digital tube, that is, one more decimal point (DP). This decimal point can more accurately represent what the digital tube wants to display; according to how many (8) can be displayed, it can be divided into 1, 2, 3, 4, 5, 6, 7 and other digital tubes.

According to the connection mode of light-emitting diode unit, it can be divided into common anode digital tube and common cathode digital tube. The common positive digital tube refers to the digital tube that connects the anodes of all the light emitting diodes together to form a common anode (COM). When the common positive digital tube is used, the common pole COM should be connected to + 5V, when the cathode of a certain field is extremely low, the corresponding field is lit, and when the cathode of a certain field is extremely high, the corresponding field is not bright. The common cathode digital tube refers to the digital tube that connects the cathodes of all the light emitting diodes together to form a common cathode (COM). When the common cathode digital tube is used, the common pole COM should be connected to the ground wire GND. When the anode of a certain field is high, the corresponding field is lit, and when the anode of a certain field is extremely low, the corresponding field is not bright.

1-bit common positive digital tube circuit diagram

What we are using today is a 1-bit common positive digital tube of 5161BS model. First, take a look at its circuit schematic diagram:

On the left is the definition of each tube of the digital tube, from the top A tube to the G tube in the middle, and the DP tube of the decimal point. By combining the differences between A tube and G tube on and off, digital information can be displayed. For example, if you light up the five ABCDG tubes, you will be able to display the number 3.

The figure on the left also contains the number of pins. From the front, put the decimal point in the lower right corner, pins 1 to 5 from left to right below, and pins 6 to 10 from right to left above. The numbering of these 10 pins is very important because you need to understand the functional definition of each pin in order to decide how to input the voltage signal through the pin.

On the right is the circuit schematic diagram, the upper layer is pin 3 or pin 8, which is the common positive, the middle layer is the A tube to the DP tube, that is, the eight tubes of the digital tube, and the lower layer is the remaining 8 pins of the 10 pins. The A tube to the DP tube, we can treat each tube as a LED lamp, with positive and negative electrodes, positive input high voltage, negative input GND, you can make a single tube of the digital tube lit up. For example, pin 3 inputs a high voltage, and pin 7 inputs a voltage difference between the two ends of a low-voltage GND,A tube, which can make the A tube light up; but if pin 7 also inputs a high voltage and there is no voltage difference between the 2 ends of the A tube, the A tube will go out.

Wiring diagram

Before starting to connect the hardware circuit, the first thing to do is to turn off the raspberry pie computer and power it off. Because if the raspberry pie motherboard is charged, the plugging circuit may lead to the burning of electronic components, so it is important to remember:

The motherboard must be powered off when connecting the circuit.

Pictures are drawn using Fritzing. For more sample pictures, please visit the official website of Fritzing.

The circuit principle diagram

Sample code

#! / usr/bin/env python# encoding: utf-8''' this program achieves 9-> 0 countdown effect wiring diagram: RPi digital7 311 713 615 429 231 133 935 1037 5'''import RPi.GPIO as GPIOimport time# pins used in positive 5'''import RPi.GPIO as GPIOimport time# _ POWER = 11LED_B = 13LED_C = 15LED_D = 29LED_E = 31LED_F = 35LED_DP = 3 "reset digital tube Extinguish all digital def reset (): GPIO.output (LED_POWER, GPIO.LOW) GPIO.output ((LED_A, LED_B, LED_C, LED_D, LED_E, LED_F, LED_G, LED_DP), GPIO.HIGH)

Save the file as

Digital-1.py

And run it.

This is the answer to sudo python digital-1.py 's question about how the raspberry pie Python uses a digital tube to display the digital countdown. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report