Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!



Hot Tub Led Light P...
 
Share:
Notifications
Clear all

[Solved] Hot Tub Led Light Project

11 Posts
2 Users
0 Reactions
2,310 Views
(@kylegap)
Active Member
Joined: 6 years ago
Posts: 8
Topic starter  

Hi,

I need to replace the Led light in my hot tub and want to make my own using a 4x4 led strip. I'll be using the same circuit, and the way it works is that each time you power off and on the light, it makes a different pattern. 

So I need the Arduino to execute a different pattern each time it's powered on.... is that possible?

THanks!


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
 

When using the code of the Led Effects All in one project, you could modify it to actually do this.

You can modify the void loop() to make a random selection. 

Modify this part:

void loop() { 
  EEPROM.get(0,selectedEffect); 
  
  if(selectedEffect>18) { 
    selectedEffect=0;
    EEPROM.put(0,0); 
  } 
  
  switch(selectedEffect) {

to this:

void loop() { 
  selectedEffect=random(18); // assuming there are 18 effects
 switch(selectedEffect) {

The entire EEPROM part has been removed and has been replaced by a random selection (0 to 18).

Now the random function of the Arduino is most certainly not the best random generator.
To improve the randomness, you can add the following line to the void setup() function;

randomSeed(analogRead(0));

Hope this helps ... curious to see what the end result will be 


   
ReplyQuote
(@kylegap)
Active Member
Joined: 6 years ago
Posts: 8
Topic starter  

That's hot... it kinds of work, but would there be a way to not make it random.... just so it execute the next pattern everytime to turn it off then on? And I had to remove every break; in the code so it sticks to the same pattern cause it was randoming from one to another in a constant loop.

So, if there was a way to instead of making it random, just a pattern after another.... I guess we would have to store this information for the next power on? is that possible?


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
 

You're right, I made a little boo-boo there.

Change void Setup() to:

void setup() 
{
  FastLED.addLeds<WS2811, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  digitalWrite (BUTTON, HIGH); // internal pull-up resistor 
  // -> remove the attach interrupt line
  // -> and add this:
  EEPROM.get(0,selectedEffect); // get previous effect selectedEffect++; // increase by 1
  if(selectedEffect>18) {  // if the new value>18 then reset value=0
    selectedEffect=0;
    EEPROM.put(0,0); 
  } 

}

Modify the original loop (keep the breaks in there!), so it looks like this (disable the EEPROM functions in the loop()):
Note: you'll have to put the "break" calls back again.

void loop() { 
  // EEPROM.get(0,selectedEffect); 
  //
  // if(selectedEffect>18) { 
  //   selectedEffect=0;
  //   EEPROM.put(0,0); 
  // } 

  
  switch(selectedEffect) {

And finally you can remove the void changeEffect() function.


   
ReplyQuote
(@kylegap)
Active Member
Joined: 6 years ago
Posts: 8
Topic starter  

Wasn't working, was always playing the Strobe pattern, so I made a modification and seems to work well now, here is what I added to your code:

void setup()
{
  FastLED.addLeds<WS2811, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  digitalWrite (BUTTON, HIGH); // internal pull-up resistor
   EEPROM.get(0,selectedEffect); // get previous effect
  selectedEffect++; // increase by 1 
  if(selectedEffect>18) { // if the new value>18 then reset value=0
    selectedEffect=0;
    EEPROM.put(0,0); 
  }
<span style="text-align: initial;">  EEPROM.put(0,selectedEffect); // Write new effect value to EEPROM
</span>}

   
ReplyQuote
(@kylegap)
Active Member
Joined: 6 years ago
Posts: 8
Topic starter  

I'm repairing my Hot Tub currently, should be running again this week. I'll make a video with the light color effects, will be nice! hehe! Cheers man, thanks for the help, it's awesome!


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
 

Awesome - glad you got it to work 

Would you mind posting the final sketch? Maybe others can benefit from it as well.
And ... I'll be looking forward to the end result! 


   
ReplyQuote
(@kylegap)
Active Member
Joined: 6 years ago
Posts: 8
Topic starter  
Want the full code? I attached the file to this reply.

So here is the .ino file of my first version sketch for my Hot Tub. I will be modifying this to remove the "no compatible hot tub" patterns and replace/add new "hot tub friendly" light patterns. 
I already replace the "Case 3" (Halloween Eyes) with a custom one that fades slowly from color to another covering all spectrum. I like this one, it's relaxing.
Thanks to Hans, can't wait to try it in the Hot Tub.


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
 

Awesome! 

Also note; this line can be removed from the void setup();

digitalWrite (BUTTON, HIGH);  // internal pull-up resistor

It was used for the toggle button, but you do not have a use for it anymore .

Thanks for posting the sketch! 


   
ReplyQuote
(@kylegap)
Active Member
Joined: 6 years ago
Posts: 8
Topic starter  

Here's the result: https://youtu.be/u-xAkMBmfKM

I added a credit link to this thread in the YouTube description. Thanks again Hans!


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
 

Nicely done!!! 

Glad I could help you out with this - it looks pretty cool! Now I need to go get myself a hot tub 


   
ReplyQuote
Share: