#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();
}文章来源:https://www.toymoban.com/news/detail-858935.html
void main()
{
main02();
}文章来源地址https://www.toymoban.com/news/detail-858935.html
到了这里,关于利用单片机余晖依次显示,同时显示 数码管的数字的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!