当前位置:网站首页>蓝桥杯——最小框架
蓝桥杯——最小框架
2022-06-29 06:39:00 【2020级机器人实验班】
只包含按键和数码管部分

#include "stc15.h" //或着是 REG52.h 建议是 STC15.h
#define uchar unsigned char
#define uint unsigned int
#define FOSC 12000000L
/*变量定义*/
uchar Trg=0,Cont=0,flag=0;
uchar menu,set,add,sub;
uchar code LedChar[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
/* 声明 */
void Init();
void Timer_Init();
void BTN();
void display_u();
void Delay100us();
/* 函数 */
void main()
{
Init();
Timer_Init();
while(1)
{
if(flag)
{
flag=0;
BTN();
if(Trg&0x08)
{
menu++;
if(menu==4) menu =1;
}
else if(Trg&0x04)
{
set++;
if(set==3) set =1;
}
else if(Trg&0x02)
{
if(menu ==3) add++;
}
else if(Trg&0x01)
{
if(menu ==3) sub++;
}
}
}
}
void timer0() interrupt 1
{
static uint flag_cnt=0,dis_cnt=0;
flag_cnt++;
if(flag_cnt==10)
{
flag=1;
flag_cnt=0;
}
dis_cnt++;
if(dis_cnt==5)
{
dis_cnt=0;
display_u();
}
}
void Init()
{
P2=0XA0;
P0=0;
P2=0X80;
P0=0XFF;
}
void BTN()
{
unsigned char dat=P3^0xff;
Trg = dat & (dat^Cont);
Cont = dat;
}
void Timer_Init()
{
AUXR |= 0x80;
TL0 = 0xCD;
TH0 = 0xD4;
TR0 = 1;
ET0 = 1;
EA = 1;
}
void display_u()
{
uchar dis[8],i;
dis[0]=0Xc1;//0Xc1 0X88
dis[1]=0XFF ;
dis[2]=0XFF;
dis[3]=0XFF;
dis[4]=0XFF;
dis[5]=0XFF;
dis[6]=0XFF;
dis[7]=0XFF;
for(i=1;i<8;i++)
{
if(dis[i]==LedChar[0])
{
dis[i]=0xff;
}
else break;
}
for(i=0;i<8;i++){
P2&=0x1f;
P0=1<<i;
P2|=0xc0;
P2&=0x1f;
P0=dis[i];
P2|=0xe0;
Delay100us();
P0=0xff;
}
P2&=0x1f;
}
void Delay100us() //@12.000MHz
{
unsigned char i, j;
i = 2;
j = 39;
do
{
while (--j);
} while (--i);
}边栏推荐
- Markdown 技能树(3):标题
- 【软件测试】接口——基本测试流程
- Alternative writing of if else in a project
- VPS是干嘛用的?有哪些知名牌子?与云服务器有什么区别?
- 【翻译】簇拥而出。构建现代应用程序的设计方法
- Markdown skill tree (1): introduction to markdown
- What does VPS do? What are the famous brands? What is the difference with ECS?
- 软件测试面试如何正确谈论薪资?
- Redis in NoSQL database (4): redis publishing and subscription
- Redis of NoSQL database (I): Installation & Introduction
猜你喜欢

部署Prometheus-server服务 system管理

In vscade, how to use eslint to lint and format

Crawler data analysis (introduction 2-re analysis)

Spark RDD案例:统计每日新增用户

ShapeShifter: Robust Physical Adversarial Attack on Faster R-CNN Object Detector

HANA数据库License的查看申请及安装

Uniapp obtains the date implementation of the beginning and end of the previous month and the next month

Redis of NoSQL database (II): introduction to redis configuration file
How to view software testing training? Do you need training?

MFC中利用CDockablePane实现悬浮窗
随机推荐
Spark RDD case: Statistics of daily new users
SAP UI5 初学 ( 一 )、简介
Livedata source code appreciation - basic use
matlab 多普勒效应产生振动信号和处理
Use of parameter in Simulink for AUTOSAR SWC
Spark RDD案例:统计每日新增用户
测试人员需要了解的工具有哪些
利用IPv6实现公网访问远程桌面
Solve the problem that NPM does not have permission
JVM系列之对象深度探秘
2022.6.27-----leetcode.522
IMX6DL4.1.15支持EIM总线(上)——实际操作,修改内容。
Domestic code hosting center code cloud
Genicam gentl standard ver1.5 (3) Chapter 4
Imx6dl4.1.15 supports EIM bus (Part 2) - configuration principle analysis.
tf.compat.v1.assign
TREE ALV 展开Node或者点击Toolbar按钮时DUMP(CL_ALV_TREE_BASE==============CP|SET_ITEMS_FOR_COLUMN)
YGG pilipinas: typhoon Odette disaster relief work update
查看tensorflow是否支持GPU,以及测试程序
节流的两种写法-最近看到的这种写法