当前位置:网站首页>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();
}
}
边栏推荐
- 2022 electrician (elementary) examination question bank and electrician (elementary) simulation examination question bank
- [Yugong series] February 2022 attack and defense world advanced question misc-83 (QR easy)
- Push technology practice | master these two tuning skills to speed up tidb performance a thousand times!
- Format character%* s
- 12. Gettimeofday() and time()
- Neo4j learning notes
- Key knowledge of embedded driver
- Node solves cross domain problems
- Why can't it run (unresolved)
- Idea if a class cannot be found, it will be red
猜你喜欢
The "message withdrawal" of a push message push, one click traceless message withdrawal makes the operation no longer difficult
The boss said: whoever wants to use double to define the amount of goods, just pack up and go
false sharing
Advanced learning of MySQL -- Application -- storage engine
Applet graduation design is based on wechat course appointment registration. Applet graduation design opening report function reference
MySQL advanced SQL statement (1)
Small program graduation design is based on wechat order takeout small program graduation design opening report function reference
Valentine's Day - 9 jigsaw puzzles with deep love in wechat circle of friends
Johnson–Lindenstrauss Lemma
Zblog collection plug-in does not need authorization to stay away from the cracked version of zblog
随机推荐
Global and Chinese market of small batteries 2022-2028: Research Report on technology, participants, trends, market size and share
A. Min Max Swap
16. System and process information
Gee import SHP data - crop image
Example 072 calculation of salary it is known that the base salary of an employee of a company is 500 yuan. The amount of software sold by the employee and the Commission method are as follows: Sales
Jerry's modification setting status [chapter]
Leetcode 110 balanced binary tree
Servlet simple verification code generation
A fan summed up so many interview questions for you. There is always one you need!
Key knowledge of C language
What are the main investment products of bond funds and what are they
High level application of SQL statements in MySQL database (I)
Data collection and summary
Node solves cross domain problems
Amélioration de l'efficacité de la requête 10 fois! 3 solutions d'optimisation pour résoudre le problème de pagination profonde MySQL
Life cycle of instance variables, static variables and local variables
Remote work guide
Méthode de calcul de la connexion MSSQL de la carte esp32c3
JVM performance tuning and practical basic theory - medium
Iclr2022 | ontoprotein: protein pre training integrated with gene ontology knowledge