题目概述:
单片机静态数码管显示。
编程:
#include <reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar str[5]={0x76,0x79,0x38,0x38,0x3F};
sbit a=P1^5;
sbit b=P1^6;
sbit c=P1^7;
void A(uchar location,number)
{
switch(location)
{
case 1:c=1,b=1,a=1;break;
case 2:c=1,b=1,a=0;break;
case 3:c=1,b=0,a=1;break;
case 4:c=1,b=0,a=0;break;
case 5:c=0,b=1,a=1;break;
case 6:c=0,b=1,a=0;break;
case 7:c=0,b=0,a=1;break;
case 8:c=0,b=0,a=0;break;
}
P2=str[number];
}
void main()
{
A(7,1);
while(1);
}
模拟实践:
Proteus:单片机静态数码管显示
最新推荐文章于 2024-04-06 13:08:12 发布