Awes0meE / 66CCFF LabXJTLU Undergraduate西交利物浦大学本科生
Back to work返回项目

Arduino Breadboard Digital Clock CounterArduino 面包板两位数码管计数器

A sophomore-year MEC104 breadboard build around Arduino Nano, SN54LS47 decoder chips, two seven-segment displays, BCD digit splitting, and pause/reset switch logic.大二 MEC104 工程实训里的面包板小项目:Arduino Nano、SN54LS47 译码芯片、两位七段数码管、BCD 拆位显示,以及暂停/复位开关逻辑。

Timeline时间线
2024.04 - 2024.052024.04 - 2024.05
Status状态
Completed已完成
Stack技术栈
ArduinoEmbeddedSeven-Segment DisplayBCDBreadboardCourse Project
Arduino Breadboard Digital Clock Counter

Project Brief项目简介

This page is for a sophomore-year MEC104 engineering practice project. The final report describes the build as an Arduino-controlled decoder system: the Arduino writes BCD signals, the SN54LS47 / 7447-style chips decode them, and two seven-segment displays show the count. The breadboard also had two button inputs for reset and pause.

这页整理的是大二 MEC104 工程实训里留下的一个面包板项目。作业报告里把它写成一个 Arduino 控制译码器的系统:Arduino 输出 BCD 信号,SN54LS47 / 7447 这一类芯片负责译码,两位七段数码管负责显示计数值,旁边再接两个按键输入,用来做复位和暂停。

当时我对嵌入式和电子元器件还很新,项目也还没有走到 PCB。所有东西都摊在面包板上,反而把问题暴露得很直接:译码芯片怎么接,个位和十位怎么分,按键电平怎么读,限流和数码管公共端怎么处理。报告现在看起来有些英语表达不顺,但里面留下的实现细节比单纯一张成品照有用。

Breadboard digital-clock counter prototype / 面包板上的两位数码管计数器原型
Breadboard digital-clock counter prototype面包板上的两位数码管计数器原型

Rules Became Wiring规则落到接线

The course brief asked for two-digit display, roll-over counting, pause, and reset. The report makes the wiring split more concrete: unitInputs[4] connects to D9, D10, D11, and D12 for the units digit, while tensInputs[4] connects to D5, D6, D7, and D8 for the tens digit. The two switches use D2 and D3. Once the project is written that way, the "digital clock" is really a few small paths that have to agree with each other.

课件里的要求是两位显示、到指定数字后归零、暂停和复位。作业报告把接线拆得更具体:unitInputs[4] 接 D9、D10、D11、D12,负责个位;tensInputs[4] 接 D5、D6、D7、D8,负责十位;两个开关接 D2 和 D3。这样一写,“数字钟”就被拆成了几条必须互相对上的小链路。

报告里还提到一个当时会拖时间的点:七段数码管公共端和课件示意不完全一致。实物按阳极数码管去接时,中间公共脚要接到 VCC;课件里更像是在讲阴极数码管接法。这个差异不大,但对刚开始接线的人来说很容易让显示结果变得莫名其妙。

Course project requirement slide / 课程项目目标页
Course project requirement slide课程项目目标页
Basic two-digit and button requirements / 两位显示与按键要求
Basic two-digit and button requirements两位显示与按键要求
Two-digit wiring from the homework report / 作业报告里的两位数码管接线图
Two-digit wiring from the homework report作业报告里的两位数码管接线图

Circuit Pieces电路拆分

The circuit became easier to debug once I stopped seeing it as one pile of jumper wires. Arduino pins generate BCD signals, the SN54LS47 maps those four bits to seven-segment outputs, the display shows the decoded digit, and the buttons feed state changes back into the program. With that split, "the number is wrong," "the decoder wiring is wrong," and "the button level is unstable" become three different checks.

后来把电路拆开看会好调很多。Arduino 引脚输出 BCD 信号,SN54LS47 把四位输入译码成七段输出,数码管负责显示,按键再把暂停和复位状态送回程序。这样一拆,“数字不对”“译码器接错”“按键电平不稳”就不是同一个问题,可以一段一段查。

Course system structure / 课程中的系统结构拆分
Course system structure课程中的系统结构拆分
BCD decoder notes / BCD 到七段译码器说明
BCD decoder notesBCD 到七段译码器说明
Button pull-up and pull-down notes / 按键上下拉说明
Button pull-up and pull-down notes按键上下拉说明

Program Logic From The Report报告里的程序逻辑

The report records the part that the smaller sketch does not show: the finished two-digit counter separates a number into units and tens. unitNum = Num % 10 takes the units digit, and tensNum = (Num / 10) % 10 takes the tens digit. Each digit then writes four BCD bits to its own decoder path. The delay(1000) call gives the visible one-second rhythm.

报告里补上了小 sketch 里没有完全展开的两位计数逻辑:先把一个数字拆成个位和十位。unitNum = Num % 10 取个位,tensNum = (Num / 10) % 10 取十位,然后每一位都按自己的 BCD 四位输出到对应译码器。delay(1000) 则让显示节奏变成肉眼能看到的一秒一次。

Digit split code from the homework report / 作业报告里的个位和十位拆分代码
Digit split code from the homework report作业报告里的个位和十位拆分代码

The report also gives the group-specific behavior: group A17 counted from 16 to 17, then returned to zero and continued counting if the switches were not touched. That detail matters because the roll-over point was not just a generic 99 -> 00 display exercise; it came from the course rule tied to the group number.

报告里还写了小组规则:A17 组从 16 增加到 17,然后回到 0;如果不操作开关,后面继续往 99 计数。这个细节给普通的 99 -> 00 显示练习加了一层课程规则:归零点跟小组号有关。

Switch Logic开关逻辑

The switch part is where the report feels closest to the actual debugging scene. One paragraph describes using the switch level to decide the state, and the later note says the six-pin key switch took time to figure out. The final wiring used a 10k ohm pull-up resistor to VCC, with the other side grounded, so the Arduino pin reads low when the switch is pressed.

开关这一段最接近真实调试现场。报告前面写的是用开关电平判断状态,后面又补了一句:6-pin 按键按下时到底哪条路径导通,当时并不确定,花了一些时间才弄清楚。实际接法是用 10k 欧姆上拉电阻接到 VCC,另一端接地,所以按下时 Arduino 引脚读到低电平。

Switch logic code from the homework report / 作业报告里的开关逻辑代码
Switch logic code from the homework report作业报告里的开关逻辑代码

This also explains why the separate digital-read-key.ino file is worth keeping. It only reads the pause and reset inputs and prints them through Serial, but that small test turns the switch wiring into something observable before the full counter logic gets mixed in.

这也解释了为什么 digital-read-key.ino 这个单独的小文件值得留着。它只读取暂停和复位输入,再通过串口打印出来,但这个小测试能在完整计数逻辑混进来之前,先把开关接线变成可观察的东西。

The other sketch, single-digit-bcd-counter.ino, checks the display side. It maps pins 9, 10, 11, and 12 to BCD inputs, uses a lookup table for digits 0 to 9, and increments once per second. The final build is the two-digit counter in the photo and demo video, but this one-digit sketch is where the decoder logic is easiest to see.

另一个 sketch single-digit-bcd-counter.ino 则是在查显示这边。它把 9、10、11、12 号引脚接成 BCD 输入,用查表数组表示 0 到 9,再每秒递增一次。最终成品是照片和演示视频里的两位计数器,但这一位数码管的 sketch 最容易看清译码逻辑。

Files And Evidence文件和证据

Looking Back现在回头看

This project came before my later STM32 and PCB work. I still did not draw PCBs at that point, and many component-level ideas were fuzzy. Looking back, the useful part is that the whole system stayed visible: jumper wires, decoder chips, current-limiting resistors, common-anode/cathode confusion, button levels, Serial prints, and two digits changing in front of me.

这条项目线发生在后来的 STM32 和 PCB 经历之前。那时我还不会画 PCB,对很多元器件原理也比较模糊。现在回头看,它有价值的地方正是所有东西都看得见:跳线、译码芯片、限流电阻、共阳/共阴接法的困惑、按键电平、串口打印,还有眼前真的在变化的两位数字。嵌入式里的输入、输出、状态和调试,在这个阶段第一次具体了一点。

Development Notes开发笔记

Project notes connected to hardware, firmware, documentation, and archive material.和这个项目相关的硬件、固件、文档和归档笔记。

Open notes archive打开笔记归档

Public Project Files公开项目资料

Uploaded evidence served from the public asset folder. Use the file index to preview documents, source code, media, PDFs, and downloadable artifacts without leaving the page.这里列出已经上传到公开目录的项目证据。可以在左侧索引里选择文件,在右侧直接预览文档、源码、媒体、PDF 和可下载附件。

16 files16 个文件

Related Media相关媒体

Images, videos, board renders, and public evidence connected to this project.和这个项目相关的图片、视频、板卡渲染图和公开证据。

Open media gallery打开媒体库
Arduino digital clock counter prototype

Arduino digital clock counter prototypeArduino 两位数码管计数器原型

Wiring overview for the Arduino, two decoder chips, two seven-segment displays, resistors, and pause/reset buttons.Arduino、两颗译码芯片、两位七段数码管、电阻和暂停/复位按键的接线总览。

Digital clock counter demo

Digital clock counter demo数字钟计数器演示

Short public MP4 showing the breadboard counter running on the desk.面包板计数器在桌面上运行的短视频。

Digital clock course requirements

Digital clock course requirementsDigital Clock 课程要求页

Course slide defining two-digit roll-over behavior plus pause and reset buttons.课程课件中关于两位归零计数、暂停和复位按键的要求页。

Digital clock block structure

Digital clock block structure数字钟功能块结构

Course slide splitting the build into Arduino, decoder, and display blocks.课程课件中把项目拆成 Arduino、译码器和显示模块的结构页。

BCD-to-seven-segment decoder notes

BCD-to-seven-segment decoder notesBCD 到七段译码器说明

SN7447 / SN54LS47 orientation, power, resistor, and BCD mapping notes from the course handout.课件中关于 SN7447 / SN54LS47 方向、电源、限流电阻和 BCD 映射的说明。

Button pull-up and pull-down notes

Button pull-up and pull-down notes按键上下拉说明

Course slide used while checking pause/reset button wiring and stable input levels.检查暂停/复位按键接线和稳定输入电平时对应的课程页。

Digital clock milestones

Digital clock milestones数字钟项目里程碑

Milestone slide that breaks the work into timing generator, decoder, display, programming, and testing.把项目拆成计时发生器、译码器、显示、程序和测试的里程碑页。

One-digit TinkerCAD demo

One-digit TinkerCAD demo一位数码管 TinkerCAD demo

Reference one-digit roll-over simulation used to understand the BCD counter path.用于理解 BCD 计数链路的一位归零计数仿真参考页。

Two-digit wiring from the homework report

Two-digit wiring from the homework report作业报告里的两位数码管接线图

Report excerpt showing Arduino, two decoder chips, two seven-segment displays, resistors, and switch wiring on a breadboard.作业报告截图,展示 Arduino、两颗译码芯片、两位七段数码管、电阻和按键在面包板上的接线。

Digit-splitting code from the homework report

Digit-splitting code from the homework report作业报告里的个位和十位拆分代码

Report code excerpt using modulo and division to split Num into units and tens before writing BCD outputs.作业报告里的代码截图,用取余和除法把 Num 拆成个位和十位,再写入 BCD 输出。

Switch logic from the homework report

Switch logic from the homework report作业报告里的开关逻辑代码

Report excerpt showing pause/reset switch state checks and pressed/released flags.作业报告里的开关代码截图,展示暂停/复位状态读取和 pressed/released 标志位。