当前位置:网站首页>Experience summary of the 12th Blue Bridge Cup (written for the first time)
Experience summary of the 12th Blue Bridge Cup (written for the first time)
2022-07-04 02:27:00 【Xiao Cong doesn't want to be bald】
DS18B20 The read , It can be written directly on the bus c In the program . How to deal with reading decimals , Delay rewriting of the underlying file of the single bus *4 , Last delay by 70-100
Use of matrix keyboard : Press the key to assign variables , It is also necessary to carry out anti shake treatment ( The same goes for independent keys ) Matrix keyboard assignment Assign values from high to low
iic Bus :dac Collection (0x43), Photosensitive resistor (0X01), Potentiometer (0x03),24c02 Of (0xa0,0xa1) Writing All of them can be put directly on iic in
dac collection Put the data directly ,0-255 The corresponding is 0-5; Show the voltage by yourself dac The output voltage is given by oneself *51
The digital tube displays decimals , In addition, create a display function ,P0 The broken code of &0x7f
Interface display function : utilize switch Statement to implement , Create variables to implement , Use the addition and subtraction of variables to realize ,
#include <STC15F2K60S2.H>
#include "onewire.h"
#include "iic.h"
#define uint unsigned int
#define uchar unsigned char
sbit L1=P3^0;
sbit L2=P3^1;
sbit L3=P3^2;
sbit L4=P3^3;
sbit C1=P3^4;
sbit C2=P3^5;
sbit C3=P4^2;
sbit C4=P4^4;
unsigned char code SMG_NoDot[18] ={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,
0x80,0x90,0x88,0x80,0xc6,0xc0,0x86,0x8e
,0xb6,0x86};
uint date1; // temperature
uint dat2;
uchar state,num1;
uchar a=25;
bit mode=0;
void xz(unsigned char 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 smg_bite(unsigned char pos,date)
{
xz(6);
P0=0x01<<pos;
xz(7);
P0= SMG_NoDot[date];
}
void smg_all()
{
xz(6);
P0=0x00;
xz(7);
P0=0xff;
}
void smgfloat(unsigned char pos,date)
{
xz(6);
P0=0x01<<pos;
xz(7);
P0= SMG_NoDot[date]&0x7f;
}
void delay(uint i)
{
while(i--);
}
void key()
{
L4=0;
L2=L3=L1=1;
C1=C2=C3=C4=1;
if(C4==0)
{
num1=4;
}while(C4==0);
if(C3==0)
{
num1=8;
}while(C3==0);
if(C2==0)
{
num1=12;
}while(C2==0);
if(C1==0)
{
num1=16;
}while(C1==0);
L3=0;
L2=L4=L1=1;
C1=C2=C3=C4=1;
if(C4==0)
{
num1=5;
}while(C4==0);
if(C3==0)
{
num1=9;
}while(C3==0);
if(C2==0)
{
num1=13;
}while(C2==0);
if(C1==0)
{
num1=17;
}while(C1==0);
L2=0;
L3=L4=L1=1;
C1=C2=C3=C4=1;
if(C4==0)
{
num1=6;
}while(C4==0);
if(C3==0)
{
num1=10;
}while(C3==0);
if(C2==0)
{
num1=14;
}while(C2==0);
if(C1==0)
{
num1=18;
}while(C1==0);
L1=0;
L2=L4=L3=1;
C1=C2=C3=C4=1;
if(C4==0)
{
num1=7;
}while(C4==0);
if(C3==0)
{
num1=11;
}while(C3==0);
if(C2==0)
{
num1=15;
}while(C2==0);
if(C1==0)
{
num1=19;
}while(C1==0);
}
void xswd()
{
date1= wendu();
smg_bite(0,19);
delay(500);
smg_bite(4,date1/1000);
delay(500);
smgfloat(5,date1%1000/100);
delay(500);
smg_bite(6,(date1%100)/10);
delay(500);
smg_bite(7, date1%10);
delay(500);
smg_all();
}
void xsdac()
{
uchar t;
date1=wendu();
if(mode==1)
{
if(date1<a*100)
{
DAC(0);
smgfloat(5,0);
delay(500);
smg_bite(6,0);
delay(500);
smg_bite(7,0);
delay(500);
smg_all();
}
else if(date1>a*100)
{
DAC(255);
smgfloat(5,5);
delay(500);
smg_bite(6,0);
delay(500);
smg_bite(7,0);
delay(500);
smg_all();
}
}
else if(mode==0)
{
if(date1<=2000)
{
DAC(51);
smgfloat(5,1);
delay(500);
smg_bite(6,0);
delay(500);
smg_bite(7,0);
delay(500);
smg_all();
}
else if(date1>=4000)
{
DAC(204);
smgfloat(5,4);
delay(500);
smg_bite(6,0);
delay(500);
smg_bite(7,0);
delay(500);
smg_all();
}
else if(date1>2000 && date1<4000)
{
t=0.0015*date1-2;
DAC(t*51);
smgfloat(5,t/100);
delay(500);
smg_bite(6,(t%100)/10);
delay(500);
smg_bite(7,t%10);
delay(500);
smg_all();
}
}
}
void cssz()
{
smg_bite(0,18);
delay(500);
smg_bite(6,a/10);
delay(500);
smg_bite(7,a%10);
delay(500);
smg_all();
}
void keypro()
{
if(num1==4)
{
state++;
if(state==3)
{
state=0;
}
}
if(num1==8&& state==1)
{
a--;
}
if(num1==9&& state==1)
{
a++;
}
if(num1==5)
{
mode=~mode;
}
num1=0;
}
void xsgn()
{
switch(state)
{
case 0:xswd();break;
case 1:cssz();break;
case 2:xsdac();break;
}
}
void led()
{
xz(4);
if(state==0&&mode==1)
{
P0=0xfe;
}
if(state==0)
{
P0=0xfd;
}
if(state==1)
{
P0=0xfb;
}
if(state==2)
{
P0=0xf7;
}
}
void main()
{
while(1)
{
key();
keypro();
xsgn();
led();
}
}边栏推荐
- Servlet simple verification code generation
- It's corrected. There's one missing < /script >, why doesn't the following template come out?
- What are the conditions for the opening of Tiktok live broadcast preview?
- Neo4j learning notes
- 3D game modeling is in full swing. Are you still confused about the future?
- Applet graduation project based on wechat selection voting applet graduation project opening report function reference
- LV1 previous life archives
- Create real-time video chat in unity3d
- C learning notes: C foundation - Language & characteristics interpretation
- Bugku Zhi, you have to stop him
猜你喜欢

What is the intelligent monitoring system of sewage lifting pump station and does it play a big role

Will the memory of ParticleSystem be affected by maxparticles

Network byte order

Take you to master the formatter of visual studio code

Bacteriostatic circle scanning correction template

LV1 tire pressure monitoring

16. System and process information

Override and virtual of classes in C #

7 * 24-hour business without interruption! Practice of applying multiple live landing in rookie villages
![[Yugong series] February 2022 attack and defense world advanced question misc-83 (QR easy)](/img/36/e5b716f2f976eb474b673f85363dae.jpg)
[Yugong series] February 2022 attack and defense world advanced question misc-83 (QR easy)
随机推荐
Crawler practice website image batch download
Question C: Huffman tree
A fan summed up so many interview questions for you. There is always one you need!
[untitled] the relationship between the metauniverse and digital collections
High level application of SQL statements in MySQL database (I)
Measurement fitting based on Halcon learning [4] measure_ arc. Hdev routine
MySQL advanced (Advanced) SQL statement (I)
Global and Chinese market of contour projectors 2022-2028: Research Report on technology, participants, trends, market size and share
2022 R2 mobile pressure vessel filling certificate examination and R2 mobile pressure vessel filling simulation examination questions
Advanced learning of MySQL -- Application -- storage engine
Solve the problem that the tabbar navigation at the bottom of vantui does not correspond to the page (window.loading.hash)
IPv6 experiment
Servlet simple verification code generation
C learning notes: C foundation - Language & characteristics interpretation
Network byte order
AI 助力藝術設計抄襲檢索新突破!劉芳教授團隊論文被多媒體頂級會議ACM MM錄用
It's corrected. There's one missing < /script >, why doesn't the following template come out?
A. Div. 7
Applet graduation design is based on wechat course appointment registration. Applet graduation design opening report function reference
On Valentine's day, I code a programmer's exclusive Bing Dwen Dwen (including the source code for free)