当前位置:网站首页>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();
}
}边栏推荐
- Basic concepts and common methods of syntactic dependency analysis
- [js] generate random array
- 同花顺股票开户是安全的吗?
- How can the cloud disk service be connected to the server? How many hard disks can the server mount?
- Redis encapsulation instance
- Experiment 5 module, package and Library
- Salesforce heroku (IV) application in salesforce (connectedapp)
- v-chart
- How to write test cases efficiently?
- The printed picture is dark. It will make you clear in seconds
猜你喜欢

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

HDLBits-&gt; Circuits-&gt; Arithmetic Circuitd-&gt; 3-bit binary adder

Outlook開機自啟+關閉時最小化

发现一个大佬云集的宝藏硕博社群!

Leetcode must review six lintcode (28348455116385)

Sending network request in wechat applet
![Harmonyos application development -- mynotepad[memo][api v6] based on textfield and image pseudo rich text](/img/b1/71cc36c45102bdb9c06e099eb42267.jpg)
Harmonyos application development -- mynotepad[memo][api v6] based on textfield and image pseudo rich text

Freshman girls' nonsense programming is popular! Those who understand programming are tied with Q after reading

个税怎么算?你知道吗

Smart cockpit SOC competition upgraded, and domestic 7Nm chips ushered in an important breakthrough
随机推荐
Chrome extension development Chinese tutorial-1
Analysis of Alibaba cloud Tianchi competition -- prediction of o2o coupon
How to create cloud disk service how to create cloud disk service backup?
Unusual transaction code mebv of SAP mm preliminary level
Xgboost implements text classification and sklearn NLP library tfidfvectorizer
Uncover the secrets of Huawei cloud enterprise redis issue 16: acid'true' transactions beyond open source redis
Make it simple. This wave of global topology is quite acceptable!
ZABBIX custom monitoring item (server monitoring)
Basic concepts and common methods of syntactic dependency analysis
股票开户要找谁?网上开户安全么?
[js] 生成随机数组
Supplement to fusionui form component
小程序ssl证书过期是什么原因导致的?小程序ssl证书到期了怎么解决?
同花顺股票开户是安全的吗?
Using clion to realize STM32F103 lighting LED
High quality "climbing hand" of course, you have to climb a "high quality" wallpaper
What is the reason for the error when calling API prompt 401 after easycvr replaces the version?
Redis encapsulation instance
How to batch generate video QR code
What are the processing methods for PPT pictures