【C51单片机期末复习整理系列】[二]数码管显示

MARK-数码管循环显示内容(编写时注意宏定义的out

#include "reg51.h"
#include "intrins.h"
#define uchar unsigned char
#define uint unsigned int 
#define out P0

uchar code seg[] = {0xc0,0xa4,0x99,0x82,0x80,0xf9,0xb0,0x92,0xf8,0x90,0x01};

void delay(unsigned int xms)
{
unsigned int x,y;
for(x=xms;x>0;x--)
for(y=110;y>0;y--);
}

void main(){
    uchar i;
    while(1){
    out = seg[i];
    delay(900);
    i++;
    if(seg[i]==0x01) i=0;
    }
}

你可能感兴趣的:(【C51单片机期末复习整理系列】[二]数码管显示)