Pages: [1]   Go Down
Author Topic: Lilypad circuit questions - new user  (Read 7310 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm new to the e-textiles thing, but relatively familiar with LEd circuitry in general and hand embroidery.

I'm working on a new Iron Man inspired cosplay, and I'd really like to use the Lilypad system to create an arc reactor prop that's sewn in to the fabric of the costume itself. I'm thinking I'll probably need at least ten white LEDs and something with an on/off switch. However, I've never used a board to connect things so I'm not sure what I'll need on that front.

(basically I need a circle of lights that I can turn on and off, sewn into a top I'm making. the placement of other components is pretty flexible at this point. I'll be adding pieces over it to diffuse the light as needed)

This is what I've been looking at so far: https://www.sparkfun.com/wish_lists/61849 will these things work for what I want to do or should I be looking somewhere else?
Logged

Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can attach those LEDs directly to the LilyPad pads and program it to do whatever you want them to do.  Here's an example of all the pads fading an LED:
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

another newb here.  Anyone know the code used in the above video?

Also, curious where a good place ppl to go to share code?
Logged

Offline Offline
Edison Member
*
Karma: 29
Posts: 2443
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
// Fade all IO by Osamu Iwasaki
// November 10, 2010

#include <MsTimer2.h>

#define OUT_MIN 0  // First pin
#define OUT_MAX 19  // Last pin (this includes the analog pins)

byte luminance[20];
byte lumi[20] = {};

void setup()
{
 int i;

 for(i = OUT_MIN; i <= OUT_MAX; i++){
   pinMode(i, OUTPUT);
   digitalWrite(i,LOW);
 }


 for(i = OUT_MIN; i <= OUT_MAX; i++){
   digitalWrite(i,HIGH);
   delay(150);
 }
 for(i = OUT_MIN; i <= OUT_MAX; i++){
   digitalWrite(i,LOW);
   //delay(50);
 }
 delay(1000);

 MsTimer2::set(1, int_pwm);
 MsTimer2::start();
}


void int_pwm() {

 static int f_wait[20];
 static int f_max_time[20];
 static int f_speed[20];
 static int f_ct[20];
 static long f_interval[20];

 static int ch;

 for(ch = OUT_MIN; ch <= OUT_MAX; ch++){
   if(f_wait[ch] == 0){
     f_wait[ch] = f_speed[ch] + 1;

     if( (f_ct[ch] < 255) )
       if(luminance[ch] != 255)
         luminance[ch] ++;

     if(f_ct[ch] == 255){
       if(f_max_time[ch] == 0)
         f_max_time[ch] = 0; // On Max Time
       else
         f_max_time[ch] --;
     }

     if( (f_ct[ch] > 255) && (f_ct[ch] < 511) && (f_max_time[ch] == 0))
       if(luminance[ch] != 0)
         luminance[ch] --;

     if(f_ct[ch] >= 511){
       if(f_interval[ch] == 0){
         f_interval[ch] = 10 * random(100); // fading seed
         f_speed[ch] = random(100); // fading speed
         f_ct[ch] = 0;
       }
       else
         f_interval[ch] --;
     }
     else
       f_ct[ch] ++;
   }
   f_wait[ch] --;
 }
}

void fading(){

 static byte counter = 0;
 static boolean prev_off[20];
 int i;

 for(i = OUT_MIN; i <= OUT_MAX; i++){
   if(lumi[i] == 0){
     if(prev_off[i] == HIGH){
       digitalWrite(i,LOW);
       prev_off[i] = LOW;
     }
   }
   else
     lumi[i] --;
 }

 counter --;

 if(counter == 0){
   for(i = OUT_MIN; i <= OUT_MAX; i++){
     if(luminance[i]){
       digitalWrite(i,HIGH);
       prev_off[i] = HIGH;
     }
     lumi[i] = luminance[i];
   }
 }
}


void loop(){
 fading();
}

Logged

Pages: [1]   Go Up
Jump to: