做的时长最久的作品。差不多一个月了。大家看图
RGB LED 俗称 全彩LED
限流电阻
由于是单层版,需要多一层,就用胶布贴上,要接通的地方打孔
全部LED的RGB三个极都是并联的,RGB每个极的控制三极管
下面8个三极管:把全部led分成8组, 每一组的正极都有一个三极管控制
后面布线
一张全部线都布好的不小心删掉了。。。这张图是没布好的
点亮测试
随便写了个程序
蒙张纸
效果
电源模块,带移动电源功能
最终效果: 流水灯变色,变色过程是单组LED渐变色视频地址: http://v.youku.com/v_show/id_XODk0MDI5MDc2.html flash: http://v.youku.com/v_show/id_XODk0MDI5MDc2.html
下面附上源程序:#include<reg52.h>
sbit gg=P3^3;
sbit bb=P3^4;
sbit rr=P3^5;
sbit h1=P1^0;sbit h2=P1^1;sbit h3=P1^2;sbit h4=P1^3;sbit h5=P1^4;sbit h6=P1^5;sbit h7=P1^6;sbit h8=P1^7;
void ON(unsigned int r)
{
switch(r)
{
case(1):h1=0;break;
case(2):h2=0;break;
case(3):h3=0;break;
case(4):h4=0;break;
case(5):h5=0;break;
case(6):h6=0;break;
case(7):h7=0;break;
case(8):h8=0;break;
case(0):break;
}
}
void OFF(unsigned int r)
{
switch(r)
{
case(1):h1=1;break;
case(2):h2=1;break;
case(3):h3=1;break;
case(4):h4=1;break;
case(5):h5=1;break;
case(6):h6=1;break;
case(7):h7=1;break;
case(8):h8=1;break;
case(0):break;
}
}
void R_GTB(unsigned char r,aaa,bbb,ccc,ddd,eee,fff,ggg)
{
unsigned int a,c,e,x=0,h=125;
unsigned int code b=125,d=125,f=125;
while(h--)
{
for(a=0;a<b;a++)
{
if(x==a){ON(r);}
rr=1;rr=0;
}
OFF(r);OFF(aaa);OFF(bbb);OFF(ccc);OFF(ddd);OFF(eee);OFF(fff);OFF(ggg);
for(c=0;c<d;c++)
{
if(x==c){ON(r);}
gg=1;gg=0;
}
P1=0xFF;ON(r);ON(aaa);ON(bbb);ON(ccc);ON(ddd);ON(eee);ON(fff);ON(ggg);
for(e=0;e<f;e++)
{
if(x==e){OFF(r);}
bb=1;bb=0;
}
P1=0x00;ON(r);
x=x+1;
}
}
void B_RTG(unsigned char r,aaa,bbb,ccc,ddd,eee,fff,ggg)
{
unsigned int a,c,e,x=0,h=125;
unsigned int code b=125,d=125,f=125;
while(h--)
{
for(a=0;a<b;a++)
{
if(x==a){ON(r);}
bb=1;bb=0;
}
OFF(r);OFF(aaa);OFF(bbb);OFF(ccc);OFF(ddd);OFF(eee);OFF(fff);OFF(ggg);
for(c=0;c<d;c++)
{
if(x==c){ON(r);}
rr=1;rr=0;
}
P1=0xFF;ON(r);ON(aaa);ON(bbb);ON(ccc);ON(ddd);ON(eee);ON(fff);ON(ggg);
for(e=0;e<f;e++)
{
if(x==e){OFF(r);}
gg=1;gg=0;
}
P1=0x00;ON(r);
x=x+1;
}
}
void G_BTR(unsigned char r,aaa,bbb,ccc,ddd,eee,fff,ggg)
{
unsigned int a,c,e,x=0,h=125;
unsigned int code b=125,d=125,f=125;
while(h--)
{
for(a=0;a<b;a++)
{
if(x==a){ON(r);}
gg=1;gg=0;
}
OFF(r);OFF(aaa);OFF(bbb);OFF(ccc);OFF(ddd);OFF(eee);OFF(fff);OFF(ggg);
for(c=0;c<d;c++)
{
if(x==c){ON(r);}
bb=1;bb=0;
}
P1=0xFF;ON(r);ON(aaa);ON(bbb);ON(ccc);ON(ddd);ON(eee);ON(fff);ON(ggg);
for(e=0;e<f;e++)
{
if(x==e){OFF(r);}
rr=1;rr=0;
}
P1=0x00;ON(r);
x=x+1;
}
}
void main()
{
rr=1;gg=1;bb=1;P1=0x00;
while(1)
{
R_GTB(1,0,0,0,0,0,0,0);R_GTB(2,1,0,0,0,0,0,0);R_GTB(3,1,2,0,0,0,0,0);R_GTB(4,1,2,3,0,0,0,0);
R_GTB(5,1,2,3,4,0,0,0);R_GTB(6,1,2,3,4,5,0,0);R_GTB(7,1,2,3,4,5,6,0);R_GTB(8,1,2,3,4,5,6,7);
B_RTG(1,0,0,0,0,0,0,0);B_RTG(2,1,0,0,0,0,0,0);B_RTG(3,1,2,0,0,0,0,0);B_RTG(4,1,2,3,0,0,0,0);
B_RTG(5,1,2,3,4,0,0,0);B_RTG(6,1,2,3,4,5,0,0);B_RTG(7,1,2,3,4,5,6,0);B_RTG(8,1,2,3,4,5,6,7);
G_BTR(1,0,0,0,0,0,0,0);G_BTR(2,1,0,0,0,0,0,0);G_BTR(3,1,2,0,0,0,0,0);G_BTR(4,1,2,3,0,0,0,0);
G_BTR(5,1,2,3,4,0,0,0);G_BTR(6,1,2,3,4,5,0,0);G_BTR(7,1,2,3,4,5,6,0);G_BTR(8,1,2,3,4,5,6,7);
}
}
如果大家觉得帖子不错,请点击下方“喜欢”,谢谢!THE END [ 此帖被huangyixiang在2015-02-16 09:42重新编辑 ]