当前位置:网站首页>【无标题】制作一个0-99的计数器,P1.7接按键,P2接数码管段,共阳极数码管,P3.0,P3.1接数码管位码,每按一次键,数码管显示加一。请写出单片机的C51代码
【无标题】制作一个0-99的计数器,P1.7接按键,P2接数码管段,共阳极数码管,P3.0,P3.1接数码管位码,每按一次键,数码管显示加一。请写出单片机的C51代码
2022-04-23 06:13:00 【ZLP啊~】
制作一个0-99的计数器,P1.7接按键,P2接数码管段,共阳极数码管,P3.0,P3.1接数码管位码,每按一次键,数码管显示加一。请写出单片机的C51代码
#include "reg51.h"
#include "stdio.h"
sbit in1 = P1^7;
sbit lse1 = P3^0;
sbit lse2 = P3^1;
typedef unsigned int u16;
unsigned char code SMG_duanma[11] = {
0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff};
void delay(u16 i)
{
while(i--);
}
void xianshi(int a,int b,int o)
{
P2=0xff;
lse1 =0;
lse2=1;
P2=SMG_duanma[a];
delay(1000);
P2=0xff;
if(o==1)
{
lse1 = 1;
lse2 = 0;
P2=SMG_duanma[b];
delay(1000);
}
P2=0xff;
}
void main()
{
int i=0;
int b=0;
int c=0;
while(1)
{
if(in1==0)
{
delay(100);
if(in1==0)
{
while(in1==0);
i=i+1;
while(in1!=0)
{
if(i<10)xianshi(i,0,0);
if(i>=10)xianshi(i%10,i/10,1);
if(in1==0)break;
}
P2=0xff;
}
}
}
}
如果是梅老师学生要把函数名字改一下
版权声明
本文为[ZLP啊~]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_52297353/article/details/123353610
边栏推荐
猜你喜欢
MySQL的安装与配置——详细教程
Pymysql connection database
【点云系列】Unsupervised Multi-Task Feature Learning on Point Clouds
使用 trt 的int8 量化和推断 onnx 模型
【指标】Precision、Recall
EMMC/SD学习小记
AUTOSAR从入门到精通100讲(五十一)-AUTOSAR网络管理
Machine learning II: logistic regression classification based on Iris data set
【点云系列】DeepMapping: Unsupervised Map Estimation From Multiple Point Clouds
Systrace 解析
随机推荐
Handlerthread principle and practical application
torch_geometric学习一,MessagePassing
Machine learning notes 1: learning ideas
【点云系列】Relationship-based Point Cloud Completion
CMSIS CM3源码注解
PyTorch 13. 嵌套函数和闭包(狗头)
如何利用qemu搭建SOC protoype:80行代码实现一个Cortex M4 模拟器
Write a wechat double open gadget to your girlfriend
【 planification dynamique】 différentes voies 2
AUTOSAR从入门到精通100讲(五十一)-AUTOSAR网络管理
ThreadLocal, just look at me!
Wechat applet uses wxml2canvas plug-in to generate some problem records of pictures
. net encountered failed to decode downloaded font while loading font:
PyTorch训练一个网络的基本流程5步法
How keras saves and loads the keras model
【动态规划】杨辉三角
Compression and acceleration technology of deep learning model (I): parameter pruning
免费使用OriginPro学习版
机器学习——PCA与LDA
rearrange 和 einsum 真的优雅吗