AT89C52.pdf
(596.3 KB, 下载次数: 6)
原理图QX-mini51.pdf
(154.08 KB, 下载次数: 5)
程序①:
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit P2_0 = P2^0;
sbit P2_1 = P2^1;
sbit P2_2 = P2^2;
sbit P2_3 = P2^3;
uchar num;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
void delay(uint z);
void main()
{
while(1)
{
for(num=0;num<16;num++)
{
P0=table[num];
P2_0=0;
P2_0=1;
P0=table[num];
P2_1=0;
P2_1=1;
P0=table[num];
P2_2=0;
P2_2=1;
P0=table[num];
P2_3=0;
P2_3=1;
delay(1000);
}
}
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
程序②:
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit P2_0 = P2^0;
sbit P2_1 = P2^1;
sbit P2_2 = P2^2;
sbit P2_3 = P2^3;
uchar num;
uchar code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,
0xf8,0x80,0x90};
void delay(uint z);
void main()
{
while(1)
{
for(num=0;num<16;num++)
{
P0=table[num];
P2_0 = 0;
P2_0 = 1;
P0=table[num];
P2_1 = 0;
P2_1 = 1;
P0=table[num];
P2_2 = 0;
P2_2 = 1;
P0=table[num];
P2_3 = 0;
P2_3 = 1;
delay(1000);
}
}
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
|