当前位置:网站首页>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();
}
}边栏推荐
- A. ABC
- Small program graduation project based on wechat video broadcast small program graduation project opening report function reference
- A fan summed up so many interview questions for you. There is always one you need!
- AI 助力藝術設計抄襲檢索新突破!劉芳教授團隊論文被多媒體頂級會議ACM MM錄用
- Career development direction
- Iclr2022 | ontoprotein: protein pre training integrated with gene ontology knowledge
- Résumé: entropie, énergie libre, symétrie et dynamique dans le cerveau
- Méthode de calcul de la connexion MSSQL de la carte esp32c3
- String: LV1 eat hot pot
- Network byte order
猜你喜欢
![Jerry's modification setting status [chapter]](/img/23/d6eb521943b35e543a9681a98ad3be.jpg)
Jerry's modification setting status [chapter]

Small program graduation project based on wechat video broadcast small program graduation project opening report function reference

C # learning notes: structure of CS documents

Pagoda SSL can't be accessed? 443 port occupied? resolvent

When tidb meets Flink: tidb efficiently enters the lake "new play" | tilaker team interview

The automatic control system of pump station has powerful functions and diverse application scenarios

AI 助力藝術設計抄襲檢索新突破!劉芳教授團隊論文被多媒體頂級會議ACM MM錄用

MySQL advanced SQL statement (1)
![[leetcode daily question] a single element in an ordered array](/img/3a/2b465589b70cd6aeec08e79fcf40d4.jpg)
[leetcode daily question] a single element in an ordered array
![Measurement fitting based on Halcon learning [4] measure_ arc. Hdev routine](/img/3a/cf6285ae1c01bda42874eeca9fe5b1.jpg)
Measurement fitting based on Halcon learning [4] measure_ arc. Hdev routine
随机推荐
Small program graduation project based on wechat e-book small program graduation project opening report function reference
AI 助力藝術設計抄襲檢索新突破!劉芳教授團隊論文被多媒體頂級會議ACM MM錄用
15. System limitations and options
Johnson–Lindenstrauss Lemma
The latest analysis of hoisting machinery command in 2022 and free examination questions of hoisting machinery command
Write the first CUDA program
Problems and solutions of several concurrent scenarios of redis
Why is the operation unsuccessful (unresolved) uncaught syntaxerror: invalid or unexpected token (resolved)
Push technology practice | master these two tuning skills to speed up tidb performance a thousand times!
[untitled] the relationship between the metauniverse and digital collections
Leetcode 110 balanced binary tree
Bacteriostatic circle scanning correction template
Database concept and installation
Site favorites
false sharing
Optimization theory: definition of convex function + generalized convex function
Global and Chinese market of small batteries 2022-2028: Research Report on technology, participants, trends, market size and share
The difference between int (1) and int (10)
查詢效率提昇10倍!3種優化方案,幫你解决MySQL深分頁問題
Dans la recherche de l'intelligence humaine ai, Meta a misé sur l'apprentissage auto - supervisé