赞
踩
#include <reg51.h>
//Êý×é±íʾ Êý×Ö0-9 16½øÖÆ
unsigned char arr[10] = {0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x90};
sbit q1 = P2^0;
sbit q2 = P2^1;
sbit q3 = P2^2;
sbit q4 = P2^3;
//ʱ¼ä³¤ ÒÀ´ÎÏÔʾ1234
void delay()
{
int i;
for(i = 1; i < 20000; i++){}
}
//ʱ¼ä¶Ì ͬʱÏÔʾ1234
void delay_short()
{
int i;
for(i = 1; i < 200; i++){}
}
void off()
{
q1 = 1;
q2 = 1;
q3 = 1;
q4 = 1;
}
//ÒÀ´ÎÏÔʾ1234
void main01()
{
q1 = 0;
P0 = arr[1];
delay();
off();
q2 = 0;
P0 = arr[2];
delay();
off();
q3 = 0;
P0 = arr[3];
delay();
off();
q4 = 0;
P0 = arr[4];
delay();
off();
}
//ͬʱÏÔʾ1234
void main02()
{
q1 = 0;
P0 = arr[1];
delay_short();
off();
q2 = 0;
P0 = arr[2];
delay_short();
off();
q3 = 0;
P0 = arr[3];
delay_short();
off();
q4 = 0;
P0 = arr[4];
delay_short();
off();
}
void main()
{
main02();
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。