200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > c语言数字滚动代码大全 8×8LED点阵屏仿电梯数字滚动显示单片机C程序

c语言数字滚动代码大全 8×8LED点阵屏仿电梯数字滚动显示单片机C程序

时间:2020-03-09 20:32:11

相关推荐

c语言数字滚动代码大全 8×8LED点阵屏仿电梯数字滚动显示单片机C程序

#include

#include

#include

#include

#include

#include

#include

#include

#define uchar unsigned char

#define uint unsigned int

/*-------------------------------------------------------

功能:5*7点阵表

----------------------------------------------------------*/

uchar code biao[11][8]=

{

{0x70,0x88,0x98,0xA8,0xC8,0x88,0x70,0x00}, // -0-

{0x20,0x60,0x20,0x20,0x20,0x20,0x70,0x00}, // -1-

{0x70,0x88,0x08,0x30,0x40,0x80,0xF8,0x00}, // -2-

{0xF8,0x08,0x10,0x30,0x08,0x88,0x70,0x00}, // -3-

{0x10,0x30,0x50,0x90,0xF8,0x10,0x10,0x00}, // -4-

{0xF8,0x80,0xF0,0x08,0x08,0x88,0x70,0x00}, // -5-

{0x38,0x40,0x80,0xF0,0x88,0x88,0x70,0x00}, // -6-

{0xF8,0x08,0x10,0x20,0x40,0x40,0x40,0x00}, // -7-

{0x70,0x88,0x88,0x70,0x88,0x88,0x70,0x00}, // -8-

{0x70,0x88,0x88,0x78,0x08,0x10,0xE0,0x00}, // -9-

{0x20,0x70,0xa8,0x20,0x20,0x20,0x20,0x00}// -↑-

};

/*-------------------------------------------------------

功能:扫描表

----------------------------------------------------------*/

//uchar code sao[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};

uchar code sao[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};

/*-------------------------------------------------------

功能:串口初始化,波特率9600 方式0 8 UART

-------------------------------------------------------*/

void Init_Com(void)

{

SCON = 0x00; //方式0

}

/*-------------------------------------------------------

功能:延时

-------------------------------------------------------*/

//1

void DELAY_25mS(void)

{

unsigned int x = 45438;

while (--x)

{

_nop_();

}

}

//2

delay(uchar ms)

{ // 延时子程序

uchari;

while(ms--)

{

for(i = 0; i<250; i++)

{

_nop_();

_nop_();

_nop_();

_nop_();

}

}

}

//3

delay1(t)

{

while(t--)

{

;

}

}

/*-------------------------------------------------------

功能:显示子程序

-------------------------------------------------------*/

xian()

{

uchar a;

for(a=0;a<8;a++)

{

SBUF =biao[0][a]; //串口发第一个显示字

while(!TI);

TI=0;

SBUF =biao[1][a]; //串口发第二个显示字

while(!TI);

TI=0;

SBUF =biao[3][a]; //串口发第三个显示字

while(!TI);

TI=0;

P1=sao[a]; //

delay1(100);

P1=0xff;

}

}

/*-------------------------------------------------------

主程序

功能:实现接收数据并把接收到的数据发送出去

-------------------------------------------------------*/

void main()

{

uchar ii;

Init_Com();

//SBUF = dis_7[0]; //发送数据

//while(!TI);

//TI=0;

while(1)

{

xian();

}

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。