單片機(jī)32位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) //點(diǎn)亮狀態(tài)逆時針旋轉(zhuǎn)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) //暗中逆時針轉(zhuǎn)360。(一個一個點(diǎn)亮)
{
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;
}
.........................................................................................................................................................................................................................................
評論