标题: 51单片机LED与数码管的使用 [打印本页]

作者: 7222    时间: 2020-4-20 07:03
标题: 51单片机LED与数码管的使用
本帖最后由 7222 于 2020-4-20 07:05 编辑

代码如下:
   #include<reg51.h>
sbit P0_4=P0^4;
int count=0;
char led_mod[]={0x3f,0x06,0x5b,0x4f,0x66,0x7d,0x07,0x6f,0x77,0x58,0x5e,0x79,0x71};
int0_key() interrupt 0
{
P0_4=!P0_4;
}
int1_key() interrupt 2
{
count++;
if(count>0x0f)
count=0;
P2=led_mod[count];
}
void main(){
IT0=1;
EX0=1;
EA=1;
IT1=1;
EX1=1;
P0_4=0;
P2=0x3f;
while(1);
}



仿真图如下:








欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1