当前位置:   article > 正文

利用单片机余晖依次显示,同时显示 数码管的数字

利用单片机余晖依次显示,同时显示 数码管的数字

#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();
}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/474136
推荐阅读
相关标签
  

闽ICP备14008679号