外部中断0电平方式进行数据采集,将外部中断0的次数读入单片机并从P0输出显示,
#include "reg51.h"
unsigned char duan[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
unsigned char num;
sbit k=P3^2;
void Int0() interrupt 0
{
P0=duan[num];
}
void main()
{ EA=1;
EX0=1;
while(1)
{
P0=0xc0;
do
{
num++;
}
while (!k);
do
{
num=0;
}
while (num==9) ;
}
}