软件部分:1. LED流水灯(跑马灯)
跑马灯程序:
/***********************************************/
/***********************************************/
#include
#define uchar unsigned char
#define uint unsigned int
/******ms延时子程序*************/
void delayMs(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
/******************************/
uchar code table[]=
{
0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,//从坐到右,再从右到左,逐个亮灭
0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00,//从坐到右,再从右到左,逐个点亮
0xe7,0xdb,0xbd,0x7e,0xbd,0xdb,0xe7,0xff,0xe7,0xc3,0x81,0x00,0x81,0xc3,0xe7,0xff,//说明:可自己定义流水灯样式,
0xaa,0x55,0x18,0xff,0xf0,0x0f,0x00,0xff,0xf8,0xf1,0xe3,0xc7,0x8f,0x1f,0x3f,0x7f,//直接添加进入这个数组即可。
0x7f,0x3f,0x1f,0x8f,0xc7,0xe3,0xf1,0xf8,0xff,0x00,0x00,0xff,0xff,0x0f,0xf0,0xff,
0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0xff,0xff,0xff,0xff,0x7f,0xbf,0xdf,0xef,
0xf7,0xfb,0xfd,0xfe,0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,0x00,0x00,0x00,0x00,
0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff
};
//主程序
void main()
{
uchar i;
while(1)
{ //从数组中读取数据送至P0口显示
for(i=0;i<128;i++) //对应数组里面16进制的个数
{
P0=table;
delayMs(200); //即延时大约200毫秒
}
}
}
|
|
2012-12-12 22:45:46
评论
举报
|
|
|