当前位置:网站首页>Single chip microcomputer 2 -- simple principle of digital tube dynamic display
Single chip microcomputer 2 -- simple principle of digital tube dynamic display
2022-07-20 09:18:00 【It cultivator】
1. Display on the last four digit nixie tube 0~9999
#include<reg52.h>
unsigned char code duanma[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xbf};// Segment code table of common anode nixie tube
unsigned char code weima[8]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
unsigned char tempdata[8]; // To hold 4 Digit nixie tube displays the segment code of numbers
void delay(int ms)
{
unsigned char j;
for(;ms>0;ms--)
for(j=125;j>0;j++);
}
void display(unsigned char first,unsigned char num) // Principle of nixie tube display : A state , The nixie tube lights up one bit from left to right , Multiple scans , People will look bright together
{
unsigned char i;
for(i=0;i<num;i++)
{
P1=0xff; // The total extinction here is to eliminate ghosting
P1=weima[i+first];
P0=tempdata[i];
delay(7);
P1=0xff; // The purpose of all off here is to prevent the subsequent program from taking too long to make the nixie tube look the last and brightest , The front few are darker
}
}
void main()
{
long int num,j;
while(1) // here while and j The cycle is to let the nixie tube scan several more times , This can make the time interval of the number jump longer
{
j++;
if(j==50)
{
num++;
j=0;
if(num==10000)
num=0;
}
tempdata[0]=duanma[num/1000]; // stay display() The bit code defined in is from tempdata[0] Started sweeping , therefore tempdata[0] It is the first digit displayed by the nixie tube
tempdata[1]=duanma[(num%1000)/100];
tempdata[2]=duanma[(num%100)/10];
tempdata[3]=duanma[num%10];
display(4,4); //display() The first one in indicates where to light , The second digit indicates how many people are bright
}
}
2. Use the delay function to roughly display the hours, minutes and seconds
#include<reg52.h>
unsigned char code duanma[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xbf};// Segment code table of common anode nixie tube
unsigned char code weima[8]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
unsigned char tempdata[8]; // To hold 4 Digit nixie tube displays the segment code of numbers
void delay(int ms)
{
unsigned char j;
for(;ms>0;ms--)
for(j=125;j>0;j++);
}
void display(unsigned char first,unsigned char num)
{
unsigned char i;
for(i=0;i<num;i++)
{
P1=0xff;
P1=weima[i+first];
P0=tempdata[i];
delay(3);
P1=0xff;
}
}
void main()
{
long int num,j;
while(1)
{
j++;
if(j==50)
{
num++;
j=0;
if(num==86400)
num=0;
}
tempdata[0]=duanma[(num/3600)/10];
tempdata[1]=duanma[(num/3600)%10];
tempdata[2]=0xbf;
tempdata[3]=duanma[((num%3600)/60)/10];
tempdata[4]=duanma[((num%3600)/60)%10];
tempdata[5]=0xbf;
tempdata[6]=duanma[(num%60)/10];
tempdata[7]=duanma[(num%60)%10];
display(0,8);
}
}
边栏推荐
猜你喜欢
【论文导读】Continuity Scaling: A Rigorous Framework for Detecting andQuantifying Causality Accurately
Array common methods, principle simulation, and high order of common functions
说说如何安装 Openfire
H5页面导出成pdf文件
Application of hash bucket
【論文導讀】DAG-GNN: DAG Structure Learning with GNN
Crack detection of pytoch migration learning Version (resnet50)
js Qrcode.js实现文字内容通过二维码展示
响应式布局【Responsive】 与 自适应布局 【adaptive】、单页面【SPA】 和多页面【MPA】
Horizontal comparison between distributed transaction framework Seata and Hmily
随机推荐
JS motion function encapsulation function, involving whether the speed is uniform, target value, JSON parameters, etc
MPPT power controller design
OpenCV图像位运算
百度飞桨七天训练营结营总结
YOLOv2论文中英文对照翻译
机器学习中数据集csv编码格式问题
Use of homebrew
Without programming, generate crud based on zero code of Oracle database, add, delete, modify and check restful API interface
【论文导读】Selecting Data Augmentation for Simulating Interventions
变量和简单的数据类型
【論文導讀】DAG-GNN: DAG Structure Learning with GNN
new URLSearchParams() 内置对象获取地址栏的参数 通过键的方式拿到值
如何抓取 app 网站 的数据
get post 区别 以及get 为啥比post要快
【vscode进阶初步】vscode debug
YOLOv3论文中英文对照翻译
膨胀卷积(空洞卷积)
【一些有关GraN-DAG的知识点总结】
Horizontal comparison between distributed transaction framework Seata and Hmily
【论文导读】Learning Bayesian Networks: The Combination of Knowledge and Statistical Data