单片机32位LED花样流水灯程序+原理图
时间:11-30
来源:互联网
点击:
最近有点忙,可还是腾出空来打造了一款单片机32位LED花样流水灯!......................那是没办法的,那*丝急了
这是原理图:
呵呵,原理不怎么难吧
LED心形排布图:
这是PCB,我改过了的,减少了一些限流电阻!
将PCB打印好,弄好板,装好原件,再焊接好,看,这就是成品了
部分程序:
#include
#define uchar unsigned char
uchar flag=200;
///////////////////////////////////////////////////////////////////////
uchar code Tab1[]={0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F,0xFF};
uchar code Tab2[]={0x7F,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0xFE,0xFF};
uchar code Tab3[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x00};
uchar code Tab4[]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01,0x00};
uchar code Tab11[]={0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0xff};
uchar code Tab22[]={0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x00,0xff};
////////////////////////////////////////////////////////////////////
uchar code Tab33[]={0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF};
uchar code Tab44[]={0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF};
uchar code Tab55[]={0x08,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff,0xff};
uchar code Tab5[]={0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xff};
uchar code Tab6[]={0x00,0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xff};
uchar code Tab7[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
uchar code Tab8[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
////////////////////////////////////////////////////////////////
void shansuo();
void xl();
///////////////////////////////////////////////////////////////
void delay(void)
{
unsigned char m,n;
for(m=0;m for(n=0;n<250;n++)
;
}
///////////////////////////////////
void hy1(void) //点亮状态逆时针旋转90度(一个一个灭)
{
unsigned char i;
for(i=0;i<8;i++)
{
P0=Tab11[i];P1=Tab22[i];
P2=Tab11[i];P3=Tab22[i];
delay();
}
for(i=0;i<8;i++)
{
P0=Tab44[i];P1=Tab55[i];
P2=Tab44[i];P3=Tab55[i];
delay();
}
}
///////////////////////////////////////////
void hy2(void) //暗中逆时针转360。(一个一个点亮)
{
unsigned char i;
for(flag=250;flag>0;flag=flag-50)
{
P0=0xff;P1=0xff;P2=0xff;P3=0xff;
for(i=0;i<8;i++)
{
P0=Tab11[i];
delay();
}
for(i=0;i<8;i++)
{
P2=Tab11[i];
delay();
}
for(i=0;i<8;i++)
{
P3=Tab22[i];
delay();
}
for(i=0;i<8;i++)
{
P1=Tab22[i];
delay();
}
}
flag=250;
}
.........................................................................................................................................................................................................................................
这是原理图:
呵呵,原理不怎么难吧
LED心形排布图:
这是PCB,我改过了的,减少了一些限流电阻!
将PCB打印好,弄好板,装好原件,再焊接好,看,这就是成品了
部分程序:
#include
#define uchar unsigned char
uchar flag=200;
///////////////////////////////////////////////////////////////////////
uchar code Tab1[]={0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F,0xFF};
uchar code Tab2[]={0x7F,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0xFE,0xFF};
uchar code Tab3[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x00};
uchar code Tab4[]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01,0x00};
uchar code Tab11[]={0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0xff};
uchar code Tab22[]={0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x00,0xff};
////////////////////////////////////////////////////////////////////
uchar code Tab33[]={0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF};
uchar code Tab44[]={0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF};
uchar code Tab55[]={0x08,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff,0xff};
uchar code Tab5[]={0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xff};
uchar code Tab6[]={0x00,0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xff};
uchar code Tab7[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
uchar code Tab8[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
////////////////////////////////////////////////////////////////
void shansuo();
void xl();
///////////////////////////////////////////////////////////////
void delay(void)
{
unsigned char m,n;
for(m=0;m
;
}
///////////////////////////////////
void hy1(void) //点亮状态逆时针旋转90度(一个一个灭)
{
unsigned char i;
for(i=0;i<8;i++)
{
P0=Tab11[i];P1=Tab22[i];
P2=Tab11[i];P3=Tab22[i];
delay();
}
for(i=0;i<8;i++)
{
P0=Tab44[i];P1=Tab55[i];
P2=Tab44[i];P3=Tab55[i];
delay();
}
}
///////////////////////////////////////////
void hy2(void) //暗中逆时针转360。(一个一个点亮)
{
unsigned char i;
for(flag=250;flag>0;flag=flag-50)
{
P0=0xff;P1=0xff;P2=0xff;P3=0xff;
for(i=0;i<8;i++)
{
P0=Tab11[i];
delay();
}
for(i=0;i<8;i++)
{
P2=Tab11[i];
delay();
}
for(i=0;i<8;i++)
{
P3=Tab22[i];
delay();
}
for(i=0;i<8;i++)
{
P1=Tab22[i];
delay();
}
}
flag=250;
}
.........................................................................................................................................................................................................................................
单片机LED花样流水 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)