51单片机数码管动态显示实验

2019年10月10日19:45:19 评论

本程序基于51单片机开发板<传送门>

本程序开发板原理图<传送门>,提取码: 2bkj

#include"reg52.h"
#define uint unsigned int
#define uchar unsigned char
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
void delayms(uint xms);
void main()
{
   while(1)
   {
      P1=0x01;
      P0=table[4];
      delayms(1);
      P0=0x00;
      P1=0x02;
      P0=table[3];
      delayms(1);
      P0=0x00;
      P1=0x04;
      P0=table[2];
      delayms(1);
      P0=0x00;
      P1=0x08;
      P0=table[1];
      delayms(1);
      P0=0x00;
    }
}
void delayms(uint xms)
{
   uint i,j;
   for(i=xms;i>0;i--)
      for(j=110;j>0;j--)
        ;
}

发表评论

您必须才能发表评论!