当前位置:网站首页>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();
}
}
边栏推荐
- Create real-time video chat in unity3d
- Properties of binary trees (numerical aspects)
- [untitled] the relationship between the metauniverse and digital collections
- Global and Chinese market for travel wheelchairs 2022-2028: Research Report on technology, participants, trends, market size and share
- 17. File i/o buffer
- Global and Chinese markets for electroencephalogram (EEG) devices 2022-2028: Research Report on technology, participants, trends, market size and share
- PMP daily three questions (February 14, 2022)
- WordPress collection WordPress hang up collection plug-in
- Pytoch residual network RESNET
- Node solves cross domain problems
猜你喜欢
Dans la recherche de l'intelligence humaine ai, Meta a misé sur l'apprentissage auto - supervisé
Learn these super practical Google browser skills, girls casually flirt
Introduction to graphics: graphic painting (I)
Final consistency of MESI cache in CPU -- why does CPU need cache
在尋求人類智能AI的過程中,Meta將賭注押向了自監督學習
Idea if a class cannot be found, it will be red
Redis transaction
How to subcontract uniapp and applet, detailed steps (illustration) # yyds dry goods inventory #
From the 18th line to the first line, the new story of the network security industry
What is the intelligent monitoring system of sewage lifting pump station and does it play a big role
随机推荐
The "message withdrawal" of a push message push, one click traceless message withdrawal makes the operation no longer difficult
C language black Technology: Archimedes spiral! Novel, interesting, advanced~
Small program graduation project based on wechat e-book small program graduation project opening report function reference
Chain ide -- the infrastructure of the metauniverse
Yyds dry goods inventory override and virtual of classes in C
2022 electrician (elementary) examination question bank and electrician (elementary) simulation examination question bank
Valentine's Day - 9 jigsaw puzzles with deep love in wechat circle of friends
From the 18th line to the first line, the new story of the network security industry
Save Private Ryan - map building + voltage dp+deque+ shortest circuit
Description of setting items of Jerry [chapter]
Design and implementation of redis 7.0 multi part AOF
Optimization theory: definition of convex function + generalized convex function
Leetcode 110 balanced binary tree
Global and Chinese market of box seals 2022-2028: Research Report on technology, participants, trends, market size and share
Network byte order
Advanced learning of MySQL -- Application -- storage engine
A brief talk on professional modeler: the prospect and professional development of 3D game modeling industry in China
Reading notes - learn to write: what is writing?
PTA tiantisai l1-079 tiantisai's kindness (20 points) detailed explanation
High level application of SQL statements in MySQL database (I)