Page 1 of 1

Hot Tub Led Light Project

Hot Tub Led Light Project

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.
Examples: "MacOS X - Your question", "MS Word - Your Tip or Trick".

Please note that switching to another language when reading a post will not work!
Posts will not have a translated counterpart.




RSS Feed

Home Forums Hardware Arduino Hot Tub Led Light Project

This topic contains 8 replies, has 2 voices, and was last updated by  hans 1 week, 1 day ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • 12437

    TheChug
    Participant

    Hi,

    I need to replace the Led light in my hot tub and want to make my own using a 4×4 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!

    Follow TheChug on Youtube
    https://www.youtube.com/thechug/

    12443

    hans
    Keymaster

    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 

    12447

    TheChug
    Participant

    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?

    Follow TheChug on Youtube
    https://www.youtube.com/thechug/

    12449

    hans
    Keymaster

    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.

    12451

    TheChug
    Participant

    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>}

    Follow TheChug on Youtube
    https://www.youtube.com/thechug/

    • This reply was modified 1 week, 2 days ago by  TheChug.
    • This reply was modified 1 week, 2 days ago by  TheChug.
    • This reply was modified 1 week, 2 days ago by  TheChug.
    12455

    TheChug
    Participant

    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!

    Follow TheChug on Youtube
    https://www.youtube.com/thechug/

    12457

    hans
    Keymaster

    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! 

    12459

    TheChug
    Participant
    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.

    Follow TheChug on Youtube
    https://www.youtube.com/thechug/

    • This reply was modified 1 week, 2 days ago by  TheChug.
    • This reply was modified 1 week, 2 days ago by  TheChug.
    • This reply was modified 1 week, 2 days ago by  TheChug.
    Attachments:
    12467

    hans
    Keymaster

    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! 

Viewing 9 posts - 1 through 9 (of 9 total)



You must be logged in to reply to this topic.