当前位置:网站首页>Blue Bridge Cup SCM digital tube skills
Blue Bridge Cup SCM digital tube skills
2022-07-02 03:37:00 【Super 561】
How to use nixie tube
1 How to use the nixie tube with the key switch interface to display the switch interface
Method : Define a variable to display the display interface ; Press the key to change the value of the variable ; So as to switch the display interface .
#include <STC15F2K60S2.H>
void Device_ctrl(unsigned char p2date,unsigned char p0date)// Latch control function
{
P0=p0date;
P2=(P2&0X1F)|p2date;
P2&=0X1F;
}
unsigned char smg_count;
unsigned char smg_display[8];
unsigned char smg_du[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};// Common anode segment code
unsigned char display_mode;// Interface display
void smg_show()
{
unsigned int i;
Device_ctrl(0xc0,0);
Device_ctrl(0xe0,~smg_display[i]);
Device_ctrl(0xc0,0x01<<i);
i=(i+1)%8;
}
void smg_process()
{
if(smg_count>3)
{
smg_count=0;
if(display_mode==0)// Show the first interface
{
smg_display[0]=smg_du[0];
smg_display[1]=smg_du[1];
smg_display[2]=smg_du[2];
smg_display[3]=smg_du[3];
smg_display[4]=smg_du[4];
smg_display[5]=smg_du[5];
smg_display[6]=smg_du[6];
smg_display[7]=smg_du[7];
}
if(display_mode==1)// Display the second interface
{
smg_display[0]=smg_du[1];
smg_display[1]=smg_du[2];
smg_display[2]=smg_du[3];
smg_display[3]=smg_du[4];
smg_display[4]=smg_du[5];
smg_display[5]=smg_du[6];
smg_display[6]=smg_du[7];
smg_display[7]=smg_du[8];
}
}
}
unsigned char trig_btn;
unsigned char con_btn;
unsigned int key_count;
void key_btn()// Key scan function
{
unsigned char readdate=P3^0xff;
trig_btn=readdate&(con_btn^0xff);
con_btn=readdate;
}
void key_process()// Key handling functions
{
if(key_count>10)// Scan the keys every ten milliseconds
{
key_count=0;
key_btn();
if(trig_btn==0x08)// Key s4
{
display_mode++;
if(display_mode==2)// Switch interface 0 1
{
display_mode=0;
}
}
}
}
void Timer2Init() //1 millisecond @12.000MHz
{
AUXR &= 0xFB; // Timer clock 12T Pattern
T2L = 0x18; // Set initial value of timing
T2H = 0xFC; // Set initial value of timing
AUXR |= 0x10; // Timer 2 Start timing
IE2|=0x04;
EA=1;
}
void main()
{
Timer2Init();
Device_ctrl(0x80,0xff);
while(1)
{
smg_process();
key_process();
}
}
void service_timer2() interrupt 12
{
smg_count++;
key_count++;
smg_show();
}
2 How to make the nixie tube data turn on and off in one second
Set a one second timer in the timer ; Then use a flag bit to display , If you let the nixie tube light up in one second, it will go out in one second .
#include <STC15F2K60S2.H>
void Device_ctrl(unsigned char p2date,unsigned char p0date)
{
P0=p0date;
P2=(P2&0X1F)|p2date;
P2&=0X1F;
}
unsigned char smg_count;
unsigned char smg_display[8];
unsigned char smg_du[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
unsigned char display_mode;
void smg_show()
{
unsigned int i;
Device_ctrl(0xc0,0);
Device_ctrl(0xe0,~smg_display[i]);
Device_ctrl(0xc0,0x01<<i);
i=(i+1)%8;
}
bit smg_blink;
void smg_process()
{
if(smg_count>3)
{
smg_count=0;
if(smg_blink)
{
smg_display[0]=smg_du[0];
smg_display[1]=smg_du[1];
smg_display[2]=smg_du[2];
smg_display[3]=smg_du[3];
smg_display[4]=smg_du[4];
smg_display[5]=smg_du[5];
smg_display[6]=smg_du[6];
smg_display[7]=smg_du[7];
}
else
{
smg_display[0]=0x00;
smg_display[1]=0x00;
smg_display[2]=0x00;
smg_display[3]=0x00;
smg_display[4]=0x00;
smg_display[5]=0x00;
smg_display[6]=0x00;
smg_display[7]=0x00;
}
}
}
void Timer2Init() //1 millisecond @12.000MHz
{
AUXR &= 0xFB; // Timer clock 12T Pattern
T2L = 0x18; // Set initial value of timing
T2H = 0xFC; // Set initial value of timing
AUXR |= 0x10; // Timer 2 Start timing
IE2|=0x04;
EA=1;
}
void main()
{
Timer2Init();// Timer initialization
Device_ctrl(0x80,0xff);
while(1)
{
smg_process();
}
}
void service_timer2() interrupt 12// Timer uses function
{
unsigned int time_count;// Timer timing variable
time_count++;
if(time_count>1000)// Timed for a second
{
time_count=0;
smg_blink=!smg_blink;
}
smg_count++;
smg_show();
}
3 The nixie tube displays useful data , Off if not displayed .
Method : Judge according to the ten hundreds and thousands
#include <STC15F2K60S2.H>
void Device_ctrl(unsigned char p2date,unsigned char p0date)
{
P0=p0date;
P2=(P2&0X1F)|p2date;
P2&=0X1F;
}
unsigned char smg_count;
unsigned char smg_display[8];
unsigned char smg_du[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
unsigned char display_mode;
unsigned int number=12345;
void smg_show()
{
unsigned int i;
Device_ctrl(0xc0,0);
Device_ctrl(0xe0,~smg_display[i]);
Device_ctrl(0xc0,0x01<<i);
i=(i+1)%8;
}
void smg_process()
{
if(smg_count>3)
{
smg_count=0;
if(number>9999)// If it is greater than 9999
{
smg_display[0]=0x00;
smg_display[1]=0x00;
smg_display[2]=0x00;
smg_display[3]=smg_du[number/10000];
smg_display[4]=smg_du[number/1000%10];
smg_display[5]=smg_du[number/100%10];
smg_display[6]=smg_du[number/10%10];
smg_display[7]=smg_du[number%10];
}
else if(number>999) // If it is greater than 999
{
smg_display[0]=0x00;
smg_display[1]=0x00;
smg_display[2]=0x00;
smg_display[3]=0x00;
smg_display[4]=smg_du[number/1000%10];
smg_display[5]=smg_du[number/100%10];
smg_display[6]=smg_du[number/10%10];
smg_display[7]=smg_du[number%10];
}
else if(number>99)// If it is greater than 99
{
smg_display[0]=0x00;
smg_display[1]=0x00;
smg_display[2]=0x00;
smg_display[3]=0x00;
smg_display[4]=0x00;
smg_display[5]=smg_du[number/100%10];
smg_display[6]=smg_du[number/10%10];
smg_display[7]=smg_du[number%10];
}
else if(number>9)// If it is greater than 9
{
smg_display[0]=0x00;
smg_display[1]=0x00;
smg_display[2]=0x00;
smg_display[3]=0x00;
smg_display[4]=0x00;
smg_display[5]=0x00;
smg_display[6]=smg_du[number/10%10];
smg_display[7]=smg_du[number%10];
}
else
{
smg_display[0]=0x00;
smg_display[1]=0x00;
smg_display[2]=0x00;
smg_display[3]=0x00;
smg_display[4]=0x00;
smg_display[5]=0x00;
smg_display[6]=0x00;
smg_display[7]=smg_du[number%10];
}
}
}
void Timer2Init() //1 millisecond @12.000MHz
{
AUXR &= 0xFB; // Timer clock 12T Pattern
T2L = 0x18; // Set initial value of timing
T2H = 0xFC; // Set initial value of timing
AUXR |= 0x10; // Timer 2 Start timing
IE2|=0x04;
EA=1;
}
void main()
{
Timer2Init();// Timer initialization
Device_ctrl(0x80,0xff);
while(1)
{
smg_process();
}
}
void service_timer2() interrupt 12// Timer uses function
{
smg_count++;
smg_show();
}
边栏推荐
- Failed to upgrade schema, error: “file does not exist
- halcon图像矫正
- uniapp 使用canvas 生成海报并保存到本地
- [数据库]JDBC
- In the era of programmers' introspection, five-year-old programmers are afraid to go out for interviews
- Global and Chinese market of autotransfusion bags 2022-2028: Research Report on technology, participants, trends, market size and share
- Getting started with MQ
- h5中的页面显示隐藏执行事件
- 蓝桥杯单片机省赛第五届
- Get started with Aurora 8b/10b IP core in one day (5) -- learn from the official routine of framing interface
猜你喜欢
蓝桥杯单片机省赛第九届
How to do medium and long-term stocks, and what are the medium and long-term stock trading skills?
Screenshot literacy tool download and use
Gradle foundation | customize the plug-in and upload it to jitpack
Download and use of the super perfect screenshot tool snipaste
MD5 of Oracle
MySQL index, transaction and storage engine
蓝桥杯单片机省赛第十一届
[designmode] builder model
[C Advanced] brother Peng takes you to play with strings and memory functions
随机推荐
halcon图像矫正
高性能 低功耗Cortex-A53核心板 | i.MX8M Mini
Grpc快速实践
PY3 link MySQL
Custom classloader that breaks parental delegation
Spark Tuning
[mv-3d] - multi view 3D target detection network
Class design basis and advanced
Unity脚本的基础语法(8)-协同程序与销毁方法
[HCIA continuous update] overview of dynamic routing protocol
终日乾乾,夕惕若厉
汇率的查询接口
Learn PWN from CTF wiki - ret2shellcode
< job search> process and signal
Global and Chinese markets for infant care equipment, 2022-2028: Research Report on technology, participants, trends, market size and share
Oracle common SQL
蓝桥杯单片机省赛第十一届第二场
蓝桥杯单片机省赛第五届
Oracle viewing locked tables and unlocking
Kotlin basic learning 16