虎途国际_虎途国际娱乐登陆中心_虎途国娱乐国际城

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 364|回复: 0
打印 上一主题 下一主题

偷工减料DIY3x4光立柱

[复制链接]
跳转到指定楼层
楼主
发表于 2018-6-12 15:41:31 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
参考网络资料,自己做一个3x4光力柱.  
代码是网络上下载的4x4光立方代码.
//此程序为16*4方案
byte led[]= {B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,
             B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,
             B1000,B1000,B1000,B1000,B1000,B1000,B1000,B1000,B1000,B1000,B1000,B1000,B1000,B1000,B1000,B1000,
             B0100,B0100,B0100,B0100,B0100,B0100,B0100,B0100,B0100,B0100,B0100,B0100,B0100,B0100,B0100,B0100,
             B0010,B0010,B0010,B0010,B0010,B0010,B0010,B0010,B0010,B0010,B0010,B0010,B0010,B0010,B0010,B0010,
             B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,
             B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,
             B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,
             B1111,B0000,B0000,B0000,B0000,B1110,B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,B0000,B1111,
             B0000,B0000,B1111,B0000,B0000,B0000,B0001,B1110,B1111,B0000,B0000,B0000,B0000,B1111,B0000,B0000,
             B0000,B0000,B0000,B1111,B0000,B0000,B0000,B0001,B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,
             B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,
             B0000,B0000,B0000,B1111,B0000,B0000,B0000,B0001,B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,
             B0000,B0000,B1111,B0000,B0000,B0000,B0001,B1110,B1111,B0000,B0000,B0000,B0000,B1111,B0000,B0000,
             B1111,B0000,B0000,B0000,B0000,B1110,B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,B0000,B1111,
             B0010,B0000,B0000,B0100,B1000,B0000,B0000,B0010,B0000,B0010,B1000,B0000,B0100,B0000,B0000,B0000,
             B0001,B0000,B0000,B0010,B0100,B0000,B0000,B1001,B0000,B0001,B1100,B0000,B1010,B0000,B0000,B0000,
             B1000,B0000,B0000,B0001,B0010,B0000,B0000,B1100,B0000,B1000,B0110,B0000,B0101,B0000,B0000,B0000,
             B0100,B0000,B0000,B0000,B0001,B0000,B0000,B0110,B0000,B0100,B0011,B0000,B0010,B0000,B0000,B0000,
             B0010,B0000,B0000,B0000,B0000,B0000,B0000,B0010,B0000,B0010,B0001,B0000,B0001,B0000,B0000,B0000,
             B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0001,B0000,B0001,B0000,B0000,B0000,
              B0010,B0000,B0000,B0100,B1000,B0000,B0000,B0010,B0000,B0010,B1000,B0000,B0100,B0000,B0000,B0000,
             B0001,B0000,B0000,B0010,B0100,B0000,B0000,B1001,B0000,B0001,B1100,B0000,B1010,B0000,B0000,B0000,
             B1000,B0000,B0000,B0001,B0010,B0000,B0000,B1100,B0000,B1000,B0110,B0000,B0101,B0000,B0000,B0000,
             B0100,B0000,B0000,B0000,B0001,B0000,B0000,B0110,B0000,B0100,B0011,B0000,B0010,B0000,B0000,B0000,
             B0010,B0000,B0000,B0000,B0000,B0000,B0000,B0010,B0000,B0010,B0001,B0000,B0001,B0000,B0000,B0000,
             B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0001,B0000,B0001,B0000,B0000,B0000
};
int l=sizeof(led) ;
int v=3;
int i=0;
int j=16;
int k=0;
int ledi=0;
int ledj=0;
int ledk=0;
void setup() {
for(i=0;i<=20;i++)
{
  pinMode(i,OUTPUT);
}
}
void draw_layer(int i){
  for(k=16;k<=19;k++)
   {
    digitalWrite(k,HIGH);
    //delay(10);
   }
     digitalWrite(i+16,LOW);
     //delay(10);
}
void loop() {
  for(i=0;i<=3;i++)
  {
  draw_layer(i);
   for(j=0;j<=15;j++)
  {     
  ledi=ledj+j;  
   if(led[ledi] & (1<<i))
   {
     digitalWrite(j,HIGH);
     //delay(10);
   }
   else
   {
    digitalWrite(j,LOW);
    //delay(10);
   }
  }
   delay(5);
   }
   ledk++;
   if(ledk>=v)
   {
   ledj+=16;
   ledk=0;
   }
   if(ledj>=l)
   ledj=0;
}


效果还行.

回复

使用道具 举报

高级模式  
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|虎途国际_虎途国际娱乐登陆中心_虎途国娱乐国际城 ( 浙ICP备09023225号 )

GMT+8, 2018-6-25 06:24 , Processed in 0.041327 second(s), 7 queries , File On.

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表
博评网