NO.12 基于Arduino的穿戴式LED灯条表演服

syl312 于 2013-7-10 10:36 编辑



演示视频:附上我们学生节时的表演视频,最终的效果就是如下了

项目设计初衷:来自美国达人秀的反重力团队的表演光影舞,希望制作多套这样的衣服来在学生节上进行表演。



硬件结构示意图:如下图,其中灯条用LED来表示。



简要说明:图中绿色的就是常见的电机控制板,当时时间紧,直接采用现有的电机控制板来控制LED灯条,因为LED灯条需要12V供电。同时电机控制板上已经有5V的输出,所以实际中不需要上图的5V电池,直接用12V供电就行。



程序源代码(其实比较简单):

[C++] 纯文本查看 复制代码

#define LEG 13
#define BODY 12
#define LARM 11
#define RARM 10
#define CHESTH 9
#define CHESTX 8

#define NEXT 7

int count=0;
int i=0;

void setup() {
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(5,OUTPUT);
pinMode(7,INPUT_PULLUP);
Show(0);
}

void loop() {
while(true)
{
if(isBTNNEXT())
{
i++;
Show(i);
delay(1000);
}
}
}

boolean isBTNNEXT(){
int sta=10;//usual status is HIGH,turns LOW when button press
for(int j=0;j<10;j++)
{
sta=sta-digitalRead(NEXT);
}

if(sta>=8)
return true;
else
return false;
}

void HeartBlink(int time)
{
digitalWrite(CHESTH,HIGH);
delay(time);
digitalWrite(CHESTH,LOW);
}

void Show(int part)
{
switch (part)
{
case 0:
{
allLow();
}
break;
case 1:
{
for(int j=10;j<=13;j++)
digitalWrite(j,HIGH);
delay(100);
for(int j=10;j<=13;j++)
digitalWrite(j,LOW);
delay(100);

  for(int j=10;j&lt;=13;j++)
    digitalWrite(j,HIGH);
  delay(100);
  for(int j=10;j&lt;=13;j++)
      digitalWrite(j,LOW);
  delay(100);

  for(int j=10;j&lt;=13;j++)
    digitalWrite(j,HIGH);
  delay(100);
  for(int j=10;j&lt;=13;j++)
      digitalWrite(j,LOW);
  delay(100);

  for(int j=10;j&lt;=13;j++)
    digitalWrite(j,HIGH);
  delay(100);

  digitalWrite(CHESTH,HIGH);
  delay(100);
  digitalWrite(CHESTH,LOW);
  delay(100);
  digitalWrite(CHESTH,HIGH);
  delay(100);
  digitalWrite(CHESTH,LOW);
  delay(100);

  delay(700);

  digitalWrite(CHESTH,HIGH);
  delay(100);
  digitalWrite(CHESTH,LOW);
  delay(100);
  digitalWrite(CHESTH,HIGH);
  delay(100);
  digitalWrite(CHESTH,LOW);
  delay(100);

  delay(700);

  digitalWrite(CHESTH,HIGH);
  delay(100);
  digitalWrite(CHESTH,LOW);
  delay(100);
  digitalWrite(CHESTH,HIGH);
  delay(100);
  digitalWrite(CHESTH,LOW);
  delay(100);

  delay(700);

  digitalWrite(CHESTH,HIGH);
  delay(100);
  digitalWrite(CHESTH,LOW);
  delay(100);
  digitalWrite(CHESTH,HIGH);
  delay(100);
  digitalWrite(CHESTH,LOW);
  delay(100);

  delay(700);

  digitalWrite(CHESTH,HIGH);
  delay(100);
  digitalWrite(CHESTH,LOW);
  delay(100);
  digitalWrite(CHESTH,HIGH);
  delay(100);
  digitalWrite(CHESTH,LOW);
  delay(100);

  delay(700);

  digitalWrite(CHESTH,HIGH);
  delay(100);
  digitalWrite(CHESTH,LOW);
  delay(100);
  digitalWrite(CHESTH,HIGH);
  delay(100);
  digitalWrite(CHESTH,LOW);
  delay(100);

  delay(700);

  digitalWrite(CHESTH,HIGH);
  delay(100);
}
break;

case 2:
{
  allLow();
}
break;

case 3:
{
  for(int j=9;j&lt;=13;j++)
    digitalWrite(j,HIGH);
  delay(100);
  for(int j=9;j&lt;=13;j++)
      digitalWrite(j,LOW);
  delay(100);

  for(int j=9;j&lt;=13;j++)
    digitalWrite(j,HIGH);
  delay(100);
  for(int j=9;j&lt;=13;j++)
      digitalWrite(j,LOW);
  delay(100);

  for(int j=9;j&lt;=13;j++)
    digitalWrite(j,HIGH);
  delay(100);
  for(int j=9;j&lt;=13;j++)
      digitalWrite(j,LOW);
  delay(100);

  for(int j=9;j&lt;=13;j++)
    digitalWrite(j,HIGH);
  delay(100);
  for(int j=9;j&lt;=13;j++)
      digitalWrite(j,LOW);
  delay(100);

  allHigh();
}
break;

case 4:
{
  allLow();
}
break;

case 5:
{
  allHigh();
}
break;

case 6:
{
  digitalWrite(LEG,LOW);
}
break;

case 7:
{
  allHigh();
}
break;

case 8:
{
  allLow();
}
break;

case 9:
{
  digitalWrite(RARM,HIGH);
}
break;

case 10:
{
  allLow();
}
break;

case 11:
{
  allHigh();
}
break;

case 12:
{
  allLow();
}
break;

}
if(part== 13)
{
allHigh();
digitalWrite(CHESTH,LOW);
digitalWrite(CHESTX,HIGH);
}

if(part==14);
{
  allLow();
}

switch(part){
  case 0: allLow();
  break;
  case 1: allHigh();
  break;
  case 2: allLow();
  break;
  case 3: allHigh();
  break;
  case 4: allLow();
  break;
  case 5: allHigh();
  break;
  case 6: 
  {
    allHigh();
    digitalWrite(LEG,LOW);
  }
  break;
  case 7: allHigh();
  break;
  case 8: allLow();
  break;
  case 9: digitalWrite(RARM,HIGH);
  break;
  case 10: allLow();
  break;
  case 11: allHigh();
  break;
  case 12: allLow();
  break;
  case 13: 
  {
    allHigh();
    digitalWrite(CHESTH,LOW);
    digitalWrite(CHESTX,HIGH);
  }
  break;
  case 14: allLow();
  break;
}

}

void allHigh()
{
for(int j=9;j<=13;j++)
digitalWrite(j,HIGH);
}

void allLow()
{
for(int j=8;j<=13;j++)
digitalWrite(j,LOW);
}


演示视频:附上我们学生节时的表演视频,最终的效果就是如下了
学生节精九一节目!小明的逆袭!技术宅的逆袭到来!

因为演完基本把东西都拆了,实在没办法把这个ID等放进去。我找了一下只剩下超级玛丽那里最后的旗子了,就拍了个照片,如下:





最后希望诸位多多支持投票哈!!有什么想法欢迎交流!

多谢多谢!!




via - arduino中文社区

标签: Arduino教程