利用Arduino实现数码管显示功能
@Tinbur物联网
利用Arduino实现数码管显示功能
1.实现功能的代码 1.1数码管显示滚动自定义字符串
#include SevenSegmentTM1637display(5,4);
void setup(){
display.begin();
}void loop(){
display.setBacklight(50);
display.print("123456");
}
1.2数码管显示自定义的时间
#include
#include SevenSegmentExtendeddisplay(5,4);
void setup(){
display.begin();
display.setBacklight(20);
}void loop(){
display.printTime(12,30,HIGH);
}
【利用Arduino实现数码管显示功能】1.3数码管显示秒表
#include
#include
#include
#include SevenSegmentTM1637display(5,4);
int8_t TimeDisp[] = {0x00,0x00,0x00,0x00};
unsigned char ClockPoint = 1;
unsigned char Update;
unsigned char microsecond_10 = 0;
unsigned char second;
unsigned char _microsecond_10 = 0;
unsigned char _second;
unsigned int eepromaddr;
boolean Flag_ReadTime;
#define ON 1
#define OFF 0void TimeUpdate2(void)
{
if(ClockPoint)tm1637.point(POINT_ON);
else tm1637.point(POINT_OFF);
TimeDisp[2] = _microsecond_10 / 10;
TimeDisp[3] = _microsecond_10 % 10;
TimeDisp[0] = _second / 10;
TimeDisp[1]= _second % 10;
Update = OFF;
}void TimingISR2()
{
microsecond_10 ++;
Update = ON;
if(microsecond_10 == 100)
{
second ++;
if(second == 60)
{
second = 0;
}
microsecond_10 = 0;
}
ClockPoint =(~ClockPoint) & 0x01;
if(Flag_ReadTime == 0)
{_microsecond_10 = microsecond_10;
_second = second;
}
}void readTime(){
Flag_ReadTime = 1;
if(eepromaddr == 0)
{
Serial.println("The time had been read");
_microsecond_10 = 0;
_second = 0;
}
else{
_second = EEPROM.read(-- eepromaddr);
_microsecond_10 = EEPROM.read(-- eepromaddr);
Serial.println("List the time");
}
Update = ON;
}
void saveTime()
{EEPROM.write(eepromaddr ++,microsecond_10);
EEPROM.write(eepromaddr ++,second);
}void stopwatchPause()
{
TCCR1B &= ~(_BV(CS10) | _BV(CS11) | _BV(CS12));
}void stopwatchReset()
{
stopwatchPause();
Flag_ReadTime = 0;
_microsecond_10 = 0;
_second = 0;
microsecond_10 = 0;
second = 0;
Update = ON;
}void stopwatchStart()
{
Flag_ReadTime = 0;
TCCR1B |=Timer1.clockSelectBits;
}void setup(){
display.begin();
display.setBacklight(20);
tm1637.set();
tm1637.init();
Timer1.initialize(10000);
Timer1.attachInterrupt(TimingISR2);
}void loop(){
stopwatchStart();
if(Update == ON)
{
TimeUpdate2();
tm1637.display(TimeDisp);
}
}
2.以下使用可视化编程的截图 2.1数码管滚动字符串
文章图片
2.2数码管显示自定义时间
文章图片
2.3数码管显示秒表的功能
文章图片
3.实现的效果 3.1实现滚动字符视频
数码管实现滚动字符串
3.2 实现自定义的时间
3.3实现秒表的视频
实现数码管秒表
推荐阅读
- 关于QueryWrapper|关于QueryWrapper,实现MybatisPlus多表关联查询方式
- MybatisPlus使用queryWrapper如何实现复杂查询
- python学习之|python学习之 实现QQ自动发送消息
- 孩子不是实现父母欲望的工具——林哈夫
- opencv|opencv C++模板匹配的简单实现
- Node.js中readline模块实现终端输入
- java中如何实现重建二叉树
- 人脸识别|【人脸识别系列】| 实现自动化妆
- paddle|动手从头实现LSTM
- pytorch|使用pytorch从头实现多层LSTM