#include "dis.h"
unsigned char Led1=0;
unsigned char Led2=9;
unsigned char Led3=3;
unsigned char Led4=4;
unsigned char Led5=5;
unsigned char Led6=6;
unsigned char Led7=7;
unsigned char Led8=8;
unsigned char code tab[10]=
{0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
// 0 1 2 3 4 5 6 7 8 9
void dis()//数码管显示
{
P0=tab[Led1];//
hc138(7); //段输出
hc138(0); //锁存
P0=0x01; // 0000 0001
hc138(6); //位输出
del(1);
P0=0x00; // 0000 0000
hc138(6); //位输出 关断
hc138(0); //锁存
P0=tab[Led2];//
hc138(7); //段输出
hc138(0); //锁存
P0=0x02; // 0000 0010
hc138(6); //位输出
del(1);
P0=0x00; // 0000 0000
hc138(6); //位输出 关断
hc138(0); //锁存
P0=tab[Led3];//
hc138(7); //段输出
hc138(0); //锁存
P0=0x04; // 0000 0100
hc138(6); //位输出
del(1);
P0=0x00; // 0000 0000
hc138(6); //位输出 关断
hc138(0); //锁存
P0=tab[Led4];//
hc138(7); //段输出
hc138(0); //锁存
P0=0x08; // 0000 1000
hc138(6); //位输出
del(1);
P0=0x00; // 0000 0000
hc138(6); //位输出 关断
hc138(0); //锁存
P0=tab[Led5];//
hc138(7); //段输出
hc138(0); //锁存
P0=0x10; // 0001 0 000
hc138(6); //位输出
del(1);
P0=0x00; // 0000 0000
hc138(6); //位输出 关断
hc138(0); //锁存
P0=tab[Led6];//
hc138(7); //段输出
hc138(0); //锁存
P0=0x20; // 0000 0001
hc138(6); //位输出
del(1);
P0=0x00; // 0000 0000
hc138(6); //位输出 关断
hc138(0); //锁存
P0=tab[Led7];//
hc138(7); //段输出
hc138(0); //锁存
P0=0x40; // 0000 0001
hc138(6); //位输出
del(1);
P0=0x00; // 0000 0000
hc138(6); //位输出 关断
hc138(0); //锁存
P0=tab[Led8];//
hc138(7); //段输出
hc138(0); //锁存
P0=0x80; // 0000 0001
hc138(6); //位输出
del(1);
P0=0x00; // 0000 0000
hc138(6); //位输出 关断
hc138(0); //锁存
}
void del(unsigned int x)//
{
unsigned char i, j;
unsigned int k;
for(k=0;k<x;k++)
{
i = 12;
j = 169;
do
{
while (--j);
} while (--i);
}
}
void hc138(unsigned char x)//0~7
{
x=x<<5; //0000 0rrr----rrr0 0000
P2=P2&0x1f;//0001 1111
P2=P2|x; //rrrx xxxx
}
蓝桥杯单片机竞赛数码管、键盘程序设计
需积分: 0 150 浏览量
2024-05-13
16:10:11
上传
评论
收藏 36KB RAR 举报
微康测控
- 粉丝: 11
- 资源: 2
最新资源
- TG-2024-05-23-204718255.mp4
- 候志强@181 5428 8938_20240420112107.amr
- spispispispispi
- 实验二:IP协议分析.zip
- 驱动代码驱动代码驱动代码驱动代码
- SVID_20240523_141155_1.mp4
- Code for the complete guide to tkinter tutorial
- 关于百货中心供应链管理系统.zip
- SimpleFolderIcon-master 修改Unity的Project下的文件夹图标
- A python Tkinter widget to display tile based maps
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈