⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 流水灯三种模式程序.c

📁 单片机流水灯
💻 C
字号:
#pragma  DEBUG CODE
#include<REG52.H>
//#include<stdio.h>
#include<math.h>
#include <stdio.h>        /* define I/O functions */
#include <intrins.h>
typedef unsigned int uint;
typedef unsigned char uchar;
uchar code DISP_TAB2[19]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x98,0x88,0x83,0xa7,0xa1,0x8e,0xb7,0xff,0x7f,0xf7};
                        /*  0    1    2    3    4   5      6   7    8    9    a     b   c    d    e    f    =    " "     .*/
                        /*  0    1    2    3    4   5      6   7    8    9    a     b   c    d    e    f     10   11   12*/
uchar code LIGHTCOLOR[95]={0xFE,0xfD,0xFB,0xF7,0xEF,0xDF,0xBF,0X7F,0xBF,0xDF,0xEF,0xF7,0xFB,0xfD,0XFE,0xFE,0xfD,0xFB,0xF7,0xEF,0xDF,0xBF,0X7F,0xBF,0xDF,0xEF,0xF7,0xFB,0xfD,0xFE,0xfD,0xFB,0xF7,0xEF,0xDF,0xBF,0X7F,0xBF,0xDF,0xEF,0xF7,0xFB,0xfD,0XFE,0xfD,0xFB,0xF7,0xEF,0xDF,0xBF,0X7F,0xBF,0xDF,0xEF,0xF7,0xFB,0xfD,0XFE,0xe7,0xdb,0xbd,0x7e,0xbd,0xdb,0xe7,0xdb,0xbd,0x7e,0xbd,0xdb,0xe7,0xdb,0xbd,0x7e,0xbd,0xdb,0xe7,0xFc,0xF9,0xF3,0xe7,0xcf,0x9f,0x3f,0x7e,0xF8,0xF1,0xe3,0xc7,0x8f,0x1f,0x3e,0x7c,0xf0,0x0f};
uchar data Disbuffer[4]={16,17,18,19};
void disp(void);
void	dl_us(uchar count);
void dl_ms(unsigned int count);
void writeisp(uchar x);
void main(void)
{  uchar e,k,i=0;
e=255;
while(1)
{e=LIGHTCOLOR[k];k++;writeisp(e);
 dl_ms(300);
 if(k>94)k=0;}
}
void writeisp(uchar x)
{uchar  b,a=0x01;
for(b=0;b<8;b++)
  {P15=0;
    if((x&a)==0)
       {P17=0;}
    else
        {P17=1;}
   a=a<<1;
   P15=1;
  }
   P16=0;;;
   P16=1;
   P15=0;P17=1;
}
void dl_ms(unsigned int count)//延时毫秒程序
{   uchar i;
    while(count--)
      { for(i=0;i<125;i++)
	{ ;
	}
      }
}

void	dl_us(uchar count)//延时微秒
{uchar i;
	for(i=0;i<count;i++)
	{ ; }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -