/****************************************************************
* 实 验 名 :点阵LED实验
* 实验说明 :滚动的心形点阵
******************************************************************/
#include <reg52.h>
#include <intrins.h>
#define FOSC 11059200L //晶振设置,默认使用11.0592M Hz
//#define FOSC 12000000L //晶振设置,使用12M Hz
//#define FOSC 24000000L //晶振设置,使用24M Hz
//IO接口定义
#define HANG_PORT P2
#define LIE_PORT P3
//全局变量定义
//8*8点阵LED显示字模(8个列码)
unsigned code lie_code[]={0x99,0x66,0x7e,0x7e,0xbd,0xdb,0xe7,0xff};
// 2进制{11111011, 00000001, 11101110, 10000011, 11101011, 00000000, 11101111, 11101111}
//16进制{0xfb, 0x01, 0xee, 0x83, 0xeb, 0x00, 0xef, 0xef}
/*******************************************************************************
* 函 数 名 :Delayms
* 函数功能 :实现 ms级的延时
* 输 入 :ms
* 输 出 :无
*******************************************************************************/
void Delayms(unsigned int ms)
{
unsigned int i,j;
for(i=0;i<ms;i++)
#if FOSC == 11059200L
for(j=0;j<114;j++);
#elif FOSC == 12000000L
for(j=0;j<123;j++);
#elif FOSC == 24000000L
for(j=0;j<249;j++);
#else
for(j=0;j<114;j++);
#endif
}
/*******************************************************************************
* 函 数 名 :main
* 函数功能 :主函数,滚动的心性
* 输 入 :无
* 输 出 :无
*******************************************************************************/
void main()
{
unsigned char i,k,j;
k=0x01;
while(1)
{
for(i=0;i<8;i++)
{
for(j=0;j<8;j++)
{
HANG_PORT=k;
LIE_PORT=lie_code[(i+j)%8];
Delayms(5);
k=_crol_(k,1);
}
Delayms(50);
}
}
}
滚动的心型点阵
最新推荐文章于 2022-01-11 11:08:41 发布