当前位置:网站首页>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();
}边栏推荐
- Global and Chinese market of handheld ultrasonic scanners 2022-2028: Research Report on technology, participants, trends, market size and share
- Kotlin基础学习 15
- What kind of interview is more effective?
- Pointer array & array pointer
- Docker installs canal and MySQL for simple testing and implementation of redis and MySQL cache consistency
- 蓝桥杯单片机省赛第十一届第一场
- Large screen visualization from bronze to the advanced king, you only need a "component reuse"!
- "Analysis of 43 cases of MATLAB neural network": Chapter 41 implementation of customized neural network -- personalized modeling and Simulation of neural network
- In wechat applet, the externally introduced JS is used in xwml for judgment and calculation
- What is the logical structure of database file
猜你喜欢

Learn PWN from CTF wiki - ret2shellcode

初出茅庐市值1亿美金的监控产品Sentry体验与架构

Comment élaborer une stratégie nuageuse à l'ère des nuages mixtes

Knowing things by learning | self supervised learning helps improve the effect of content risk control

Kubernetes cluster storageclass persistent storage resource core concept and use

Account management of MySQL

Haute performance et faible puissance Cortex - A53 Core Board | i.mx8m mini

蓝桥杯单片机省赛第六届

Oracle的md5

蓝桥杯单片机省赛第十一届
随机推荐
Detailed explanation of ThreadLocal
Sentry experience and architecture, a fledgling monitoring product with a market value of $100million
Go execute shell command
Oracle的md5
Class design basis and advanced
Verilog timing control
Pycharm2021 delete the package warehouse list you added
Qt的网络连接方式
Unity脚本的基础语法(7)-成员变量和实例化
Oracle viewing locked tables and unlocking
PHP array processing
Generate random numbers that obey normal distribution
Verilog reg register, vector, integer, real, time register
What is the binding path of SAP ui5
高性能 低功耗Cortex-A53核心板 | i.MX8M Mini
"Analysis of 43 cases of MATLAB neural network": Chapter 41 implementation of customized neural network -- personalized modeling and Simulation of neural network
C#聯合halcon脫離halcon環境以及各種報錯解决經曆
蓝桥杯单片机省赛第十一届第一场
Get started with Aurora 8b/10b IP core in one day (5) -- learn from the official routine of framing interface
PY3 link MySQL