当前位置:网站首页>The 10th Blue Bridge Cup single chip microcomputer
The 10th Blue Bridge Cup single chip microcomputer
2022-06-23 21:48:00 【Xiao Cong doesn't want to be bald】
matters needing attention :led The control of requires and operation before assignment ,0x03 Yes, read the voltage on the potentiometer ,0x43 dac The function is Write data
Switch of nixie tube , Control it with other flags on the
#include <STC15F2K60S2.H>
#include "iic.h"
#define uchar unsigned char
#define uint unsigned int
uint date,count,dat,volt;
bit jiemian,ad_mode,led_mode,smg_mode;
unsigned char code SMG_NoDot[18] ={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,
0x80,0x90,0x88,0x80,0xc6,0xc0,0x86,0x8e,
0xff,0xce};
sbit S7=P3^0;
sbit S6=P3^1;
sbit S5=P3^2;
sbit S4=P3^3;
void select(uchar n)
{
switch(n)
{
case 4: P2=(P2&0x1f)|0x80;
break;
case 5: P2=(P2&0x1f)|0xa0;
break;
case 6: P2=(P2&0x1f)|0xc0;
break;
case 7: P2=(P2&0x1f)|0xe0;
break;
}
}
void delay(uint i)
{
while(i--);
}
void smg_bite(uchar pos,date)
{
select(6);
P0=0x01<<pos;
select(7);
P0=date;
}
void smg_float(uchar pos,date)
{
select(6);
P0=0x01<<pos;
select(7);
P0=SMG_NoDot[date]&0x7f;
}
void inint()
{
TMOD=0x16;
TH0=0xff;
TL0=0xff;
TH1=(65535-5000)/256;
TL1=(65535-5000)%256;
ET0=1;
ET1=1;
TR0=1;
TR1=1;
EA=1;
}
void inint0() interrupt 1
{
date++;
}
void inint1() interrupt 3
{
TH1=(65535-50000)/256;
TL1=(65535-50000)%256;
count++;
if(count==20)
{
dat=date;
count=0;
date=0;
}
}
void smg_all()
{
select(6);
P0=0xff;
select(7);
P0=0xff;
}
void show_f()
{
smg_bite(0,0x8e);
delay(500);
if(dat>9999)
{
smg_bite(3,SMG_NoDot[(dat/10000)%10]);
delay(500);
}
if(dat>999)
{
smg_bite(4,SMG_NoDot[(dat/1000)%10]);
delay(500);
}
if(dat>99)
{
smg_bite(5,SMG_NoDot[(dat/100)%10]);
delay(500);
}
if(dat>9)
{
smg_bite(6,SMG_NoDot[(dat/10)%10]);
delay(500);
}
if(dat>0)
{
smg_bite(7,SMG_NoDot[dat%10]);
delay(500);
}
smg_all();
}
void show_u()
{
smg_bite(0,0xc1);
volt=read_rb2();
smg_float(5,volt/100);
delay(500);
smg_bite(6,SMG_NoDot[(volt%100)/10]);
delay(500);
smg_bite(7,SMG_NoDot[volt%10]);
delay(500);
smg_all();
}
void key()
{
if(S4==0)
{
delay(500);
if(S4==0)
{
if(jiemian==0)
{
jiemian=1;
}
else if(jiemian==1)
{
jiemian=0;
}
}while(S4==0);
}
if(S5==0)
{
delay(500);
if(S5==0)
{
if(ad_mode==0)
{
ad_mode=1;
}
else if(ad_mode==1)
{
ad_mode=0;
}
}while(S5==0);
}
if(S6==0)
{
delay(500);
if(S6==0)
{
if(led_mode==0)
{
led_mode=1;
}
else if(led_mode==1)
{
led_mode=0;
}
}while(S6==0);
}
if(S7==0)
{
delay(500);
if(S7==0)
{
if(smg_mode==0)
{
smg_mode=1;
}
else if(smg_mode==1)
{
smg_mode=0;
}
}while(S7==0);
}
}
void led()
{
select(4);
if(jiemian==0&&smg_mode==1)
{
P0&=0xfe;
}
if(jiemian==1&&smg_mode==1)
{
P0&=0xfd;
}
if(volt>=1.5&&volt<2.5)
{
P0&=0xfb;
}
if(volt>=3.5)
{
P0&=0xfb;
}
if(dat<5000&&dat>=1000)
{
P0&=0xf7;
}
if(dat>=10000)
{
P0&=0xf7;
}
if(ad_mode==1)
{
P0&=0xef;
}
}
void keypr0()
{
if(jiemian==0&&smg_mode==1)
{
show_u();
}
if(jiemian==1&&smg_mode==1)
{
show_f();
}
if(ad_mode==0&&jiemian==1)
{
DAC(volt*51);
}
if(ad_mode==1)
{
DAC(102);
}
if(led_mode==0)
{
led();
}
if(led_mode==1)
{
select(4);
P0=0xff;
}
if(smg_mode==0)
{
select(6);
P0=0xff;
select(7);
P0=0xff;
}
}
void main()
{
inint();
while(1)
{
key();
keypr0();
}
}边栏推荐
- Wechat is new. You can create applications from Excel
- How to reduce snapshots
- ECS (no matter which one, as long as it is an ordinary ECS) uses the installed version of SketchUp to install an error
- 实验五 模块、包和库
- Chrome extension development Chinese tutorial-1
- Cloud database smooth disassembly scheme
- Find My资讯|苹果可能会推出第二代AirTag,试试伦茨科技Find My方案
- CAD图在线Web测量工具代码实现(测量距离、面积、角度等)
- Surprise! Edge computing will replace cloud computing??
- Infrastructure splitting of service splitting
猜你喜欢

Find My资讯|苹果可能会推出第二代AirTag,试试伦茨科技Find My方案

个税怎么算?你知道吗

Code implementation of CAD drawing online web measurement tool (measuring distance, area, angle, etc.)

Minimisé lorsque Outlook est allumé + éteint

Find my information | Apple may launch the second generation airtag. Try the Lenz technology find my solution

Outlook开机自启+关闭时最小化

Embedded development: embedded foundation -- the difference between restart and reset

Lightweight, dynamic and smooth listening, hero earphone hands-on experience, can really create

Selenium batch query athletes' technical grades

Sending network request in wechat applet
随机推荐
Does FTP meet managed file transfer (MFT) requirements?
How does the hybrid cloud realize the IP sec VPN cloud networking dedicated line to realize the interworking between the active and standby intranet?
Full text search of MySQL
Uncover the secrets of Huawei cloud enterprise redis issue 16: acid'true' transactions beyond open source redis
Minimisé lorsque Outlook est allumé + éteint
高阶柱状图之极环图与极扇图
How many of the five app automated test AIDS have you used?
What is the use of PMP certification?
Cloud database smooth disassembly scheme
Supplement to fusionui form component
蓝牙芯片|瑞萨和TI推出新蓝牙芯片,试试伦茨科技ST17H65蓝牙BLE5.2芯片
Data visualization: summer without watermelon is not summer
Who do you want to open a stock account? Is it safe to open an account online?
SAP retail wrmo replenishment monitoring
What about the cloud disk service status error? How to format the cloud disk service?
The printed picture is dark. It will make you clear in seconds
Bcdedit, used to adjust the machine startup parameters (safe mode, BootMenu display name, CPU, memory, etc.)
Outlook開機自啟+關閉時最小化
发现一个大佬云集的宝藏硕博社群!
Analysis of Alibaba cloud Tianchi competition -- prediction of o2o coupon