Arduino与Proteus仿真实例-HT16K33驱动4位7段数码管仿真

HT16K33驱动4位段数码管仿真

七段显示模块是一种用于显示数字的电子设备,由七个LED段组成。 由于 LED 的尺寸很小,因此很容易将多个 LED 连接在一起以形成一个类似七段显示器的单元。 在七段显示模块中,七个LED排列成一个矩形。 有时,在七段显示单元中会看到一个额外的 LED,用于显示小数点。

在前面的实例中,对7段数码管做了详细的介绍,请参考:

HT16K33 是一个内存映射和多功能 LED 控制器驱动器。 设备中最大显示段数为128个模式(16段和8个公共点),带有13*3(MAX.)矩阵键扫描电路。 HT16K33 的软件配置特性使其适用于多种 LED 应用,包括 LED 模块和显示子系统。 HT16K33 与大多数微控制器兼容,并通过两线双向 I2C 总线进行通信。

在前面的实例中,对HT16K33做了相关介绍,请参考:

1、仿真电路原理图

在这里插入图片描述

2、仿真代码实现

本次使用到如下开源库:

开源库中的演示代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* 
This is a library for our I2C LED Backpacks

Designed specifically to work with the Adafruit LED 7-Segment backpacks
----> http://www.adafruit.com/products/881
----> http://www.adafruit.com/products/880
----> http://www.adafruit.com/products/879
----> http://www.adafruit.com/products/878

These displays use I2C to communicate, 2 pins are required to
interface. There are multiple selectable I2C addresses. For backpacks
with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks
with 3 Address Select pins: 0x70 thru 0x77

Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!

Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

#include <Wire.h> // Enable this line if using Arduino Uno, Mega, etc.
#include <Adafruit\_GFX.h>
#include "Adafruit\_LEDBackpack.h"

Adafruit_7segment matrix = Adafruit\_7segment();

void setup() {
#ifndef \_\_AVR\_ATtiny85\_\_
Serial.begin(9600);
Serial.println("7 Segment Backpack Test");
#endif
matrix.begin(0x70);
}

void loop() {
// try to print a number thats too long
matrix.print(10000, DEC);
matrix.writeDisplay();
delay(500);

// print a hex number
matrix.print(0xBEEF, HEX);
matrix.writeDisplay();
delay(500);

// print a floating point
matrix.print(12.34);
matrix.writeDisplay();
delay(500);

// print a string message
matrix.print("7SEG");
matrix.writeDisplay();
delay(100);

// print with print/println
for (uint16\_t counter = 0; counter < 9999; counter++) {
matrix.println(counter);
matrix.writeDisplay();
delay(10);
}

// method #2 - draw each digit
uint16\_t blinkcounter = 0;
boolean drawDots = false;
for (uint16\_t counter = 0; counter < 9999; counter ++) {
matrix.writeDigitNum(0, (counter / 1000), drawDots);
matrix.writeDigitNum(1, (counter / 100) % 10, drawDots);
matrix.drawColon(drawDots);
matrix.writeDigitNum(3, (counter / 10) % 10, drawDots);
matrix.writeDigitNum(4, counter % 10, drawDots);

blinkcounter+=50;
if (blinkcounter < 500) {
drawDots = false;
} else if (blinkcounter < 1000) {
drawDots = true;
} else {
blinkcounter = 0;
}
matrix.writeDisplay();
delay(10);
}
}


3、仿真结果

在这里插入图片描述

文章来源: https://iotsmart.blog.csdn.net/article/details/121187642