Lilypad RGB chakra dress and headdress

Hi - I hope some of you can help with some issues ( I have not yet had many experiences with arduino).

I am making a performance dress+headdress(hat) with RGB lights
now after the first initialization, i don't want anything of the RGBs to be input based but to run different loops (when one is done, it starts another, then third etc) because they have different delaytimes and patterns. i want simply a full time "show" for the time of 15 minute performance

i have tried to figure out how to make code jump to next loop when it is done with one (so let's say all RGBs are first off or BLACK for few minutes, run through being ON for a certain time, and then i want to decrease the delaytime, and then once again)...is there a smarter way of doing this than my footwork logic?

second question is that i would like to have accelorometer running simoultaneously controling whiteLEDS..they would be doing their own thing all the time not regarding the RGBs...
is there any problem with this?
I have tried some stuff with normal arduino board, but want to make sure i don't do big NONO connecting or programming things and burn lilypad chip
i hope you can help :slight_smile:
thx

For the first question, what works best is to post your Sketch. This will help us understand what you'd like to accomplish and allows us to provide specific advice that moves you towards the goal.

second question is that i would like to have accelorometer running simoultaneously controling whiteLEDS..they would be doing their own thing all the time not regarding the RGBs...
is there any problem with this?

Are you concerned about the programming or the hardware?

I have tried some stuff with normal arduino board, but want to make sure i don't do big NONO connecting or programming things and burn lilypad chip

That is certainly a valid concern. What would damage the chip is too much voltage (generally not a problem), current (always a concern), or power. Post an inventory of all the things you plan to connect to the LilyPad chip and I suspect some kind soul will provide an opinion.

thank you Coding Badly :slight_smile:

Right now, I have figured out how to do the sketch and use millis to make it run in sequences i want.

My concern with accelorometer, white (3)LEDs blinking as defined by acc. and (3) RGBs in programmed sequence was mainly hardware, because it would all be running on a single lilypad board.

The thing that remains is orange light. All the other ones i can get by using the digital pins, but this color is not one i can code the same way. So I guess I would have to use PWM to get a larger array of colors. Can I still use my RGBs as an array if all are digital and one is PWM? Does the question even make sense? i am sorry if it is very basic stuff. I have tried to read about it but have not really seen an answer that is specific to this.
Thanks

You don't neccesarily have to use PWM to get orange light. But you would need to use an additional output. That would be with the same method you already have for the other colors. That is, have two outputs with different sized resistors, each going to the green pin of the RGB LED. One you can keep as it is (for yellow, in combination with red), the other you increase the series resistance such that it looks orange in combination with the red (only one "green output" on at a time).

Or make it a combo and get 4 levels from red to yellow (00,01,10,11). For this to work in an incresingly yellow fashion, the parallel resistance of the "green1 resistor" and the "green2 resistor" needs to be the same value as you have now for the resistor to the green LED (if feasible), and at the same time the green1 resistor needs to be bigger than green2.

Of course with PWM you would get much more colors. If you are using the built-in PWM pins anyway this might be simpler.

Can I still use my RGBs as an array if all are digital and one is PWM?

Yes.

Does the question even make sense?

Generally, when the Sketch is included, questions like the one above make more sense and the answers are more helpful.

thanks for your responses
i have attempted a sketch and my RGBs work as i want them and they are timed as they should be. that is, until i include the whites.
the whites are supposed to start in the beginning and fade in and out over the whole course, and the RGBs would be changing in sequences. the code compiles, but i get whites to do their thing...only all the RGBs light and stay that way.
i have tried to say the whites should read this first time and then exit that part...but perhaps there is something i am really not understanding.
if you can, please take a look at this code for the hat part of the suit...and perhaps tell me how i could have two parallel things going. bear with me if some things are messed up...it is one of my first efforts :slight_smile:
thanks in advance :slight_smile:

const boolean ON = LOW; //Define on LOW
const boolean OFF = HIGH;
/*
const boolean RED[] = {ON, OFF, OFF};
const boolean GREEN[] = {OFF, ON, OFF};
const boolean BLUE[] = {OFF, OFF, ON};
const boolean YELLOW[] = {ON, ON, OFF};
const boolean CYAN[] = {OFF, ON, ON};
const boolean MAGENTA[] = {ON, OFF, ON};
const boolean WHITE[] = {ON, ON, ON};
*/
const boolean BLACK[] = {OFF, OFF, OFF};

//to-dimensionel array af hver LEDs 3 pin-nummre
int LEDPins[3][3] = {{2, 3, 4},
{5, 6, 7},
{8, 10, 11},};

int White = 9; // LED connected to digital pin 9

const boolean LEDColors[3][3] = {{OFF, ON, ON},
{OFF, OFF, ON},
{ON, OFF, ON}};

int prevLED = 0;
int repeat = 0;
long duration = 0;
boolean FirstTime = true;

void setup(){

pinMode (White, OUTPUT);

for(int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
pinMode(LEDPins*[j], OUTPUT); //Set the three LED pins as outputs*

  • }*

  • }*
    }
    void fadewhite (long delaytime){

  • for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5){*

  • // sets the value (range from 0 to 255):*

  • analogWrite(White, fadeValue); *

  • delay(80); *

  • // fade out from max to min in increments of 5 points:*

  • for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {*

  • // sets the value (range from 0 to 255):*

  • analogWrite(White, fadeValue); *

  • delay(100); *
    }
    }
    }
    void setColor(int* led, const boolean* color){

  • for(int i = 0; i < 3; i++){*
    digitalWrite(led_, color*);
    }
    }
    void cycleDressLEDs(long delayTime)
    {
    for (int i = 0; i < 3; i++){
    setColor(LEDPins[prevLED], BLACK);
    setColor(LEDPins, LEDColors);
    prevLED = i;
    delay(delayTime);
    }*_

* }*
* void RandomCycle(long delayTime)// randomized cycle*
* {*
* for (int i = 0; i < 3; i++){*
* int rand = random(3);*
* setColor(LEDPins[prevLED], BLACK);*
_ setColor(LEDPins[rand], LEDColors*);
delay(delayTime);
}
}*

void loop(){_

* duration = millis();*

* while (duration > 0 && duration < 900000);//length of s*
* //put them on wait*
* {*
* if (FirstTime == true)*
{
fadewhite (500);//call white and then make them do their thing over the whole duration...

* FirstTime = false;*
*} *
* //set alle til sort*
* setColor(LEDPins[0], BLACK);*
* setColor(LEDPins[1], BLACK);*
* setColor(LEDPins[2], BLACK);*

* //wait five first minutes, while poem is being read*
* delay(300000);*

* //1. sequence w light (1 minute each, align with suit)*
* for (int i = 0; i < 1; i++){*
* cycleDressLEDs(60000);*

* setColor(LEDPins[0], BLACK);*
* setColor(LEDPins[1], BLACK);*
* setColor(LEDPins[2], BLACK);*
* delay (4000);*

* }*

* //2. sequence w light (faster - align w suit)*
* for (int i = 0; i < 20; i++){*
* cycleDressLEDs(1000); *

* setColor(LEDPins[0], BLACK);*
* setColor(LEDPins[1], BLACK);*
* setColor(LEDPins[2], BLACK);*
* delay (4000);*
* }*

* //3. sequence...light - fast fast*
for (int i = 0; i < 100; i++){
* cycleDressLEDs(50);*

* setColor(LEDPins[0], BLACK);*
* setColor(LEDPins[1], BLACK);*
* setColor(LEDPins[2], BLACK);*
* delay (200);*

}
//4.random sequence

for (int i = 0; i < 5; i++){
RandomCycle(3000);

* setColor(LEDPins[0], BLACK);*
* setColor(LEDPins[1], BLACK);*
* setColor(LEDPins[2], BLACK);*

}
}

}

You need to have a look at the differences between the Blink and BlinkWithoutDelay examples.

When delay gets called, nothing happens until it returns.

Also, in fadeWhite(), you have the fade down loop inside the fade up loop. If you put the open and close curly braces on separate lines, and indented properly, you'd see this.

The Arduino resets when? Do you reset it to start the action?

When the Arduino resets, millis() starts over at 0. The loop function is called, in an endless loop. The first time it is called, this is executed:

duration = millis();
 
 while (duration > 0 && duration < 900000);//length of s

You should put this in a function called DoNothingFor15Minutes(). Is that really what you want?

Then, the fadeWhite() function is called. It returns when it has completed fading (in a strange way) the white light(s).

Then, you turn all the LEDs off, and do nothing for 5 minutes.

Next, you call cycleDressLEDs() in a loop:

 for (int i = 0; i < 1; i++){

How many times does this loop execute? i is set to 0. i is less than 1, so the body executes. Then, i is incremented, to 1. i is no longer less than 1, so, we're done looping, after 1 iteration. Well, OK.

the code compiles, but i get whites to do their thing...only all the RGBs light and stay that way.

The code compiles, but the white lights work, anyway? I wouldn't expect anything to happen if the code didn't compile. That the code compiled just means that there are no syntax errors. It does not mean that there are no logic errors.

"only all the RGBs light and stay that way". Light when? While the white LED(s) are doing there thing? After the whites get done?

Thank you PaulS

I know I have used many Delays - but in the end i did not know how to get the circuit to do what it needed.

basically it is a dress/suit with one lily pad and one hat circuit with the other lily pad. now all would last for 15 minutes, where very precise sequences need to be happening, and where they are synchronised (hat and suit). however between my wish to communicate to arduino and what i actually do communicate may be very different.

the idea is this:
suit has four RGB lights
they first wait for 1 minute (poem being read)
then they go on one by one, in preassigned colors and do only ONE cycle of about a minute
then i set them to delay to allow the same to happen for a hat
hat has 3 RGB lights and two white ones
3 RGB lights behave same as those on suit (one after the other, then turn off to allow next faster cycle on suit, and so on)
the 3 should wait about 5 minutes in total (1minute poem+sequence on suit)
whites should start after 1 minute and go on during the whole duration fading in and out regardless of what the RGBs are doing

at first i started putting all in millis, using while function and telling it to do certain things while)
but something i messed up and i understood i both used millis and delay....and so i went to delay only because things did not really work.
now i understand delay delays everything. but i am not sure what really to use to time precise sequences and still have parallel activities going on.

reason i used 900000 in beginning is because i thought i was telling it to execute all below re whites within this time (whole time).
and i set boolean thinking it would read this once only and then go on to the next.

blink without delay could do what i need and is much more elegant.
but what do i do with all these delays and am i completely messing this up.

sorry - long q....if have time, appreciate greatly!

basically my biggest issues are:
how to set them to black after each cycle (and some cylces repeat several times in different speeds) to allow for suit to run through each time.

and how to make whites do their do all the while.

thx

If I were doing this, I'd have a look at:
http://www.arduino.cc/playground/Code/TimedAction

AlphaBeta put a lot of work into this library to make life easier for you.

thanks so much for replies
have modified and code works
the only thing now is that it works while connected to computer but VERY VERY weakly when on battery....
any ideas?
thx

What kind of battery?

AAA as it says on Lily pad page
though what confuses me is that I only can find 1.5 V triple A...and it says lilypad has 5 V power...

Are you powering the Lilypad using 1 AAA battery, or are you powering it using the Lilypad power supply powered by a AAA battery?

The Sparkfun site says:

Good up to 100mA.

I'm guessing that your using far more than 100mA, if you are powering more than a couple of LEDs.

i am using the power supply and power supply is connected by + and - to lilypad and all the RGBs to each other by + then to lilypad...

How many LEDs? What voltage? What size resistors?

4 RGBs in total, however only one lit at the time.
i have not used resistors because lilypad doesn't use them (see on Leah B's site) and because the thread is also supposed to act as a resistor because some current is spent on thread.
on her site, she had 2 buttons, around 16 white LEDs all connected to the same lilypad and one battery where 7 lights are on at the same time...

so i am guessing it may be the stiching that needs reinforcing.
what troubles me is that when battery comes on, on both hat and suit one light lights and stays put in wrong(RED) color...but not with USB

Even if only one RGB LED is lit at one time, that is still 3 LEDs. With no current limiting resistor (except the thread), you are probably drawing more current than the 1 AAA battery can supply using the power supply.

I'm pretty sure that power supply is meant to power the Lilypad only. External devices like the LEDs are meant to be powered separately.

But, I don't own a Lilypad or a Lilypad power supply, so I could be all wrong. Given your description of the problem, I don't think so.