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!




LEDs: Fade-in and F...
 
Share:
Notifications
Clear all

[Solved] LEDs: Fade-in and Fade-out stair steps

13 Posts
2 Users
0 Likes
2,824 Views
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2660
Topic starter  

This is a continuation of the discussion of the Arduino WS2812 LEDs article to create lights on your stairs, which fade in and fade out step by step.

The link to the comments is: link.


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2660
Topic starter  

Hello Hans !

Yes I think it’s a really great effect for house stair, it’s really flexible and ergonomic.

My testing setup is : Fritzing draw (see attachment)

Naturally I will share this project after completing it !  

About your early morning code, it work ! But actually it block the fadeout function and the fadin effect isn’t pretty smooth . 

In a simpler way,I think it would be easier and more standard for other user to create a simple fade’in fade’out effect with a variable delay to adjust on walking pace

Hera are my actual sketch : http://www.codeshare.io/Qkley (see also attachment) then you can have an overview .

 


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2660
Topic starter  

For those interested, here a YouTube video representing the general idea.


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2660
Topic starter  

I absolutely love the idea! This looks super slick!

Pretty cool that you've started using PIR's as well - I've just ordered a bag of 10 for $10. Couldn't resist.
I'm planning of using them for an alarm system I'm planning to build together with my brother-in-law (he's the handy guy when it comes to building cases and such).

Glad to hear my pre-coffee code worked haha ...

// Fill the dots one after the other with a color
void colourWipeUp(uint32_t c, uint8_t wait) {
    
   // Convert 32 bit to 3x 8 bit RGB
   uint8_t
     r = (uint8_t)(c >> 16),
     g = (uint8_t)(c >> 8),
     b = (uint8_t)c;
      
   // Do 4 LEDs, slowly brining up brightness
   // Brightness goes from 0 .. 255
   
   for(uint16_t i=strip.numPixels(); i < -1; i=i-4) {
     for(int brightness=2; brightness <= 256; brightness=brightness*2) {
        for(int countFour=0; countFour < 4; ++countFour) {
          strip.setPixelColor(i+countFour, (r * brightness) >> 8, (r * brightness) >> 8, (r * brightness) >> 8 );
          strip.show();
          // delay(50); // possible delay here
          }
     }
   }
 }

I guess the ideal fade in/out would be per block of 4 and in that block slowly fade each individual.

For now my first attempt would be adding a few delays (which would not accomplish what I've just said) - maybe this would make it smoother, but a more natural flow would be preferred of course ...

// Fill the dots one after the other with a color
void colourWipeUp(uint32_t c, uint8_t wait) {
    
   // Convert 32 bit to 3x 8 bit RGB
   uint8_t
     r = (uint8_t)(c >> 16),
     g = (uint8_t)(c >> 8),
     b = (uint8_t)c;
      
   // Do 4 LEDs, slowly brining up brightness
   // Brightness goes from 0 .. 255
   
   for(uint16_t i=strip.numPixels(); i < -1; i=i-4) {
     for(int brightness=2; brightness <= 256; brightness=brightness*2) {
        for(int countFour=0; countFour < 4; ++countFour) {
          strip.setPixelColor(i+countFour, (r * brightness) >> 8, (r * brightness) >> 8, (r * brightness) >> 8 );
          strip.show();
          delay(50); // possible delay here
          } delay(100);
     }
   }
 }

I really need to get my hands on a few WS2812 LEDs so i can experiment along with you ... 

Let me see how fast I can get a few strands ... (I'm staying at family in Europe right now - see if I can find some local shop that can provide these LEDs ... I have PIR's and probably can find an LDR somewhere in my dad's stuff as well!)


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2660
Topic starter  

I just thought about the confusion when two people go on the stairs, one up and one down haha ... 


   
ReplyQuote


(@showtime)
Active Member
Joined: 9 years ago
Posts: 5
 
Very glad than you like this project ! This happen only if you have a big big house .  
About the PIR sensor as you said, it's a really cheap module, the consumption is low and the integration is easy. (example of price : Here
Personally I've adopted the solution of a recessed aluminum rail (see attached picture) 
 Hans, did you have any piece of WS2812B led strip to test-it ? 
 Actually, it light up but block the loop process in my sketch , the light never fade out , ( maybe you can look my codeshare) Another thing, for this code was potentially usable by all, maybe we have to declare some easy to change parameters (color, delay,.... ) ? curious to see the resul 

   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2660
Topic starter  

Sorry - had to clean up the message, for some reason a lot of HTML tags appeared - did you paste it from something?

Either way haha ... I've ordered some LEDs and a power supply, should be here within 10 days ... (slow China mail)
I'm staying with family, so no-way I can get my hands on my own stuff.

I like the idea! And I am thinking of a procedure that handles the fade with some parameters indeed.
I'll have to get back to this topic once I have the LEDs.


   
ReplyQuote
(@showtime)
Active Member
Joined: 9 years ago
Posts: 5
 

Hi Hans !

I dont know what happens with my previous message, I haven't  paste any code or something but tried several time to include my attached picture in the message without succes.  I haven't see after posting than some balis was included in my message.

Ok, I will keep updated on the project, Can I do someting before you receive the goods ?


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2660
Topic starter  

Hi ShowTime,

oh no worries - maybe it was the backend of the forum that made a mess of it. Unfortunately this forum does not properly support a rich text editor, so I had to create one myself, only to find out that the backend messes with it all the time. Oh well, such is life.

I don't think there is much you can at the moment. However, when I see how you are going to install the LEDs, that made me think of something (which would work for other installation methods as well);

We should just use a regular fade - from start to end - just add a little extra delay after each 4th LED. Now I know the swipe is not as smooth as we'd like it to be ... yet ... but maybe this gives an idea:

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) { int counter=1;
  for(uint16_t i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, c);
      strip.show();
      delay(wait); // after each 4th LED wait a little longer counter++; if(counter==4) { counter=1; delay(wait); // I just took wait for time, can be anything }
  }
}

   
ReplyQuote
(@showtime)
Active Member
Joined: 9 years ago
Posts: 5
 

Here are the actual effect :

https://youtu.be/1BpIUodD1DU


   
ReplyQuote


(@showtime)
Active Member
Joined: 9 years ago
Posts: 5
 

Hey Hans,

did you have already received your material ???

I'm excited about this project 


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2660
Topic starter  

Not yet ... 

And now comes the next delay: I'm traveling to the US today so I can start moving my stuff to Europe. I'll be online on and off, but won't be able to work on that project. I should be back after the 26th ...


   
ReplyQuote
(@showtime)
Active Member
Joined: 9 years ago
Posts: 5
 

Ok Hans no problem, have a nice trip  !

Keep me up when you are ready , and if you need any test or help


   
ReplyQuote

Like what you see and you'd like to help out? 

The best way to help is of course by assisting others with their questions here in the forum, but you can also help us out in other ways:

- Do your shopping at Amazon, it will not cost you anything extra but may generate a small commission for us,
- send a cup of coffee through PayPal ($5, $10, $20, or custom amount),
- become a Patreon,
- donate BitCoin (BTC), or BitCoinCash (BCH).

Share: