WS2812 LED Flexible 32 x 8 grid

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.

Moderators: Benj, Mods

mnf
Valued Contributor
Valued Contributor
Posts: 641
Joined: Wed May 31, 2017 11:57 am
Has thanked: 59 times
Been thanked: 358 times
Contact:

WS2812 LED Flexible 32 x 8 grid

Postby mnf » Sun Dec 01, 2019 6:53 pm

I was lucky enough to be given a 32 x 8 grid of WS2812 LEDs to play with.
(For example https://www.amazon.co.uk/Flexible-Indiv ... -4-catcorr)

This is a 'searingly' bright and very colourful display - so I thought I'd do a 'Christmas' display (more fundraising!)

I got it working with an Arduino (Nano - cheap clone) - which, surprisingly, manages to power the display from it's 5v pin. (A separate power supply is probably a good idea here though!)

First task was a scrolling text - based heavily on the MAX7219 code...

LightBoard.fcfx
(48.15 KiB) Downloaded 42 times

Then - a couple of effects - I added two TheatreChase routines based on the Adafruit demo (for NeoPixel strands) and a scrolling 'Rainbow' effect. Also a 'FadeToBlack'. There is a 'static' rainbow which needs some work.

- But, I'd like more - any suggestions for (easy) transitions/effects - or (much) better - implementations of transitions
or effects :)

Note that the code does simulate (although it doesn't run as fast as on an Arduino) - the output (esp. text) on the FC 2d panel looks a bit 'faded'. I used a dimmer colour here - because the display is painfully bright to look at.... Due to a bug in the scroll routine in the WS281x component it only works at full brightness (till Ben fixes the component - pretty please)
There is also a slight bug - on the Arduino the 'rainbow' is different (and incorrect) - red dominates more than it should...

Note - the display size is currently hardcoded as 32 * 8 (bad) - but an Arduino probably can't cope with a much bigger display (the buffer for this is 768 bytes). I'd like to add an SD card reader - to display 'bitmap' images. Should be room (512 byte buffer needed for SD reads)

Martin
These users thanked the author mnf for the post (total 3):
medelec35 (Sun Dec 01, 2019 11:31 pm) • jgu1 (Mon Dec 02, 2019 1:12 pm) • STibor (Tue Dec 03, 2019 3:06 am)
Rating: 15%
 

User avatar
Benj
Matrix Staff
Posts: 14684
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4670 times
Been thanked: 4287 times
Contact:

Re: WS2812 LED Flexible 32 x 8 grid

Postby Benj » Wed Dec 04, 2019 11:45 am

Hello,

The WS2812 LEDs are great fun. I've been playing around with this in my spare time and I'll try and make a video soon to show off what it can actually do.

https://www.amazon.co.uk/ANIGHT-Animate ... B081M6GXZ4

Note that the code does simulate (although it doesn't run as fast as on an Arduino) - the output (esp. text) on the FC 2d panel looks a bit 'faded'. I used a dimmer colour here - because the display is painfully bright to look at


I had the same problem so used the IsSim component to decide if it's the simulation or not to allow me to easily dim the hardware but the simulation remains full brightness.

Due to a bug in the scroll routine in the WS281x component it only works at full brightness (till Ben fixes the component - pretty please)


Can you show me an easy way to try and replicate this bug, I'm not aware of it. You may also want to check you are using the latest version of the component as there have been some recent changes to brightness and how this works. Hopefully the problem is already fixed :)

There is also a slight bug - on the Arduino the 'rainbow' is different (and incorrect) - red dominates more than it should...


I beleive the red LED has a slightly higher luminosity to the other two colours. Are you using the WS2812 or the WS2812B devices? The link you sent suggests the newer B version. Not sure if there is much we can do about this without scaling down the red colour channel in software.
These users thanked the author Benj for the post:
jgu1 (Thu Dec 12, 2019 10:37 pm)
Rating: 5%
 

mnf
Valued Contributor
Valued Contributor
Posts: 641
Joined: Wed May 31, 2017 11:57 am
Has thanked: 59 times
Been thanked: 358 times
Contact:

Re: WS2812 LED Flexible 32 x 8 grid

Postby mnf » Wed Dec 04, 2019 1:06 pm

Hi Ben,

I've PMd you with details of the bug...

Martin
These users thanked the author mnf for the post:
Benj (Wed Dec 04, 2019 1:40 pm)
Rating: 5%
 

User avatar
Benj
Matrix Staff
Posts: 14684
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4670 times
Been thanked: 4287 times
Contact:

Re: WS2812 LED Flexible 32 x 8 grid

Postby Benj » Wed Dec 04, 2019 1:53 pm

Hi Martin,

Shift LEDs does get the scaled colour value and attempts to re-scale back up to original. However I can see this may lead to a gradual fade as the original full depth value has been lost. Hmm not sure what I can do about this?

For example lets say brightness is 128 or 0.5

A value of 200 would get scaled down to ( 200 * 12 7) >> 8 = 99.
Then when reading back the value we would end up with ( 99 << 8 ) / 127 = 199

I'm sure there are worse case situations. Maybe I can round up rather than down? This may then have the opposite effect of making things brighter :D

I'll see if there is a way for the shift macros to bypass the brightness calculations so we are just taking the values and moving them as is. Might use a bit more ROM but should end up running faster.

Edit, think I've solved the problem for you now. New component is now on the update system and may even use less ROM :D It should certainly run faster. Rolling the fix out to the other smart LED components now.

Also forgot about the disabled code, yes this is either other chips or other LED types, basically any code that isn't needed on your current configuration.
These users thanked the author Benj for the post:
mnf (Wed Dec 04, 2019 7:07 pm)
Rating: 5%
 

mnf
Valued Contributor
Valued Contributor
Posts: 641
Joined: Wed May 31, 2017 11:57 am
Has thanked: 59 times
Been thanked: 358 times
Contact:

Re: WS2812 LED Flexible 32 x 8 grid

Postby mnf » Wed Dec 04, 2019 7:06 pm

Thanks Ben,

I've added a scrolling sinewave routine - and works ok in simulation. Out this evening so can't test on hardware till tomorrow...

Couple of other ideas:

Colour swap: Allow colour cycling 'animation'
Using an old technique - and would require rewriting the Ws281x component - would be to have a colour 'lookup table' - each colour in the display buffer would then be 4 or 8 bits (16 or 256 colours allowed) This would use a lot less memory and allow larger displays. I'm not sure my eyes can resolve 256*256*256 colours in the LEDs!

I found a an eeprom breakout - to provide storage for 'bitmaps'. (24LC256 or similar - 256k bits or 32k bytes). The FC component doesn't provide much support above a very basic read/write byte.

So I wrote a short test to use the block read/write functions of the eeprom. Anyone brave/foolish enough to test (I'd probably pull it to a (barebones) component but at present it is a standalone program) Feedback or ideas on the interface I've chosen?? Probably should pull it to a new thread - but for the moment I'll post it here.... Works well with the limited tests I've tried..

eeprom.fcfx
(22.53 KiB) Downloaded 38 times

LightBoard.fcfx
(51.81 KiB) Downloaded 41 times
(Just testing a (low res) sinewave scroll)

Martin
These users thanked the author mnf for the post (total 2):
jgu1 (Thu Dec 12, 2019 10:37 pm) • medelec35 (Tue Jan 21, 2020 8:19 am)
Rating: 10%
 

User avatar
Benj
Matrix Staff
Posts: 14684
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4670 times
Been thanked: 4287 times
Contact:

Re: WS2812 LED Flexible 32 x 8 grid

Postby Benj » Thu Dec 05, 2019 10:41 am

Hi Martin,

The bitmap drawer GLCD components should work directly with the WS2812 component allowing you to store the bitmap files in flash or on an SD card. Thought this info might help.

https://www.instructables.com/id/Easy-RGB-LED-Sign/

Some good ideas there.
These users thanked the author Benj for the post:
jgu1 (Thu Dec 12, 2019 10:38 pm)
Rating: 5%
 

mnf
Valued Contributor
Valued Contributor
Posts: 641
Joined: Wed May 31, 2017 11:57 am
Has thanked: 59 times
Been thanked: 358 times
Contact:

Re: WS2812 LED Flexible 32 x 8 grid

Postby mnf » Thu Dec 05, 2019 9:27 pm

Some cool ideas there..

Yes - the fix to scroll worked. Almost a shame - the sine wave produced an interesting 'whip' effect at 0.1 brightness.

Martin
These users thanked the author mnf for the post:
Benj (Fri Dec 06, 2019 10:49 am)
Rating: 5%
 

mnf
Valued Contributor
Valued Contributor
Posts: 641
Joined: Wed May 31, 2017 11:57 am
Has thanked: 59 times
Been thanked: 358 times
Contact:

Re: WS2812 LED Flexible 32 x 8 grid

Postby mnf » Sun Dec 08, 2019 12:07 am

Added a couple more effects + load / save to EEPROM. Added a SetLEDColourRAW to bypass brightness.

ScrollIn to scroll in image from EEPROM

+ a video - made to my usual high standards.. The TheatreRainbow section is perhaps a bit long - and I currently only have two bitmaps saved in the EEPROM (both copied from the Rainbow display)

https://youtu.be/n9Q56mYRpAQ

Martin
These users thanked the author mnf for the post:
jgu1 (Thu Dec 12, 2019 10:40 pm)
Rating: 5%
 

User avatar
Benj
Matrix Staff
Posts: 14684
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4670 times
Been thanked: 4287 times
Contact:

Re: WS2812 LED Flexible 32 x 8 grid

Postby Benj » Sun Dec 08, 2019 11:36 pm

Hi Martin,

Nice video, looking very good.

You inspired me to put up a video of mine.

https://youtu.be/r-BFg3YauG0
These users thanked the author Benj for the post:
jgu1 (Thu Dec 12, 2019 10:42 pm)
Rating: 5%
 

mnf
Valued Contributor
Valued Contributor
Posts: 641
Joined: Wed May 31, 2017 11:57 am
Has thanked: 59 times
Been thanked: 358 times
Contact:

Re: WS2812 LED Flexible 32 x 8 grid

Postby mnf » Sun Dec 08, 2019 11:54 pm

Like it - are all 6 sides lit? - and is it user programmable and/or sound activated?

I t think having a diffuser over the LEDs is a great idea - they really are a bit bright for eye comfort.

Martin.
These users thanked the author mnf for the post:
Benj (Mon Dec 09, 2019 10:36 am)
Rating: 5%
 

User avatar
Benj
Matrix Staff
Posts: 14684
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4670 times
Been thanked: 4287 times
Contact:

Re: WS2812 LED Flexible 32 x 8 grid

Postby Benj » Mon Dec 09, 2019 12:14 am

Hi Martin,

I t think having a diffuser over the LEDs is a great idea - they really are a bit bright for eye comfort.


3mm Milky White Acrylic works well but I have now moved to a thin 3D printed opaque white shell as it provides a more seamless 3D shape.

20161204_223507 - Copy.jpg
20161204_223507 - Copy.jpg (30.76 KiB) Viewed 2515 times


I also have a light sensor mounted in the top which scales the display brightness automatically, brighter when there is more light. Having them too bright when it is dark is painful :D

Yes all 6 panels are lit. No user programmability atm but it does have expansion sockets for BT or WIFI which is nice. I plan to maybe make use of this on a 4X larger model if I can find a way to reduce production time.

Not included audio yet, I've tried audio hardware in the past and I think its hard to do it well especially on a tight budget. Saying this I have had some success here so it is possible.
These users thanked the author Benj for the post (total 2):
jgu1 (Thu Dec 12, 2019 10:43 pm) • AbhijitR (Sat Jan 18, 2020 6:52 am)
Rating: 10%
 

viktor_au
Posts: 161
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 27 times
Been thanked: 42 times
Contact:

Re: WS2812 LED Flexible 32 x 8 grid

Postby viktor_au » Fri Jan 17, 2020 10:00 pm

Interesting design.
If you waterproof it and use for sailing boat mast light the skipper can change the light from white (on anchor) to some other color during the mayday situation to attract the rescue team attention.

User avatar
Benj
Matrix Staff
Posts: 14684
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4670 times
Been thanked: 4287 times
Contact:

Re: WS2812 LED Flexible 32 x 8 grid

Postby Benj » Mon Jan 20, 2020 10:50 am

Many thanks and nice idea for it, it's certainly bright enough at full whack. I've now written up the project and shared it here.
https://www.instructables.com/id/Animat ... ght-Light/
These users thanked the author Benj for the post (total 3):
viktor_au (Mon Jan 20, 2020 10:32 pm) • medelec35 (Tue Jan 21, 2020 8:24 am) • jgu1 (Wed Jan 29, 2020 6:16 am)
Rating: 15%
 

viktor_au
Posts: 161
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 27 times
Been thanked: 42 times
Contact:

Re: WS2812 LED Flexible 32 x 8 grid

Postby viktor_au » Mon Jan 20, 2020 10:32 pm

Thank you for sharing this project Ben.
These users thanked the author viktor_au for the post:
Benj (Tue Jan 21, 2020 11:07 am)
Rating: 5%
 

User avatar
Benj
Matrix Staff
Posts: 14684
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4670 times
Been thanked: 4287 times
Contact:

Re: WS2812 LED Flexible 32 x 8 grid

Postby Benj » Wed Jan 22, 2020 11:31 am

Thanks very much and glad you found it useful. Somehow I'm currently on the front page of Instructables as the first project. Time for a screenshot I think :wink: :lol:

If anyone is interested and has an Instructables account then I would appreciate a vote, I'm currently entered in a competition there. You can vote near the bottom of the page. :wink:

mnf
Valued Contributor
Valued Contributor
Posts: 641
Joined: Wed May 31, 2017 11:57 am
Has thanked: 59 times
Been thanked: 358 times
Contact:

Re: WS2812 LED Flexible 32 x 8 grid

Postby mnf » Wed Mar 11, 2020 10:50 pm

Another use for a WS2812 chip...

Not really much Flowcode here - but hopefully someone will find the idea useful (hopefully some FC to come later :-) )

- wanted to create a simple puzzle game using illuminated push buttons that can change colour... However apart from some three colour buttons (with lots of pins) I couldn't find anything that really fitted the bill.

So I hacked some illuminated pushbuttons from banggood (https://www.banggood.com/10Pcs-33MM-Ele ... rehouse=CN)

Originally I tried to use some AP102 chips I purchased - however 'easy to solder' seems to be very subjective - and after wrecking several (if anyone wants a handful of these PM me your details and I'll pop them in the post!) I decided my SMD soldering 'skills' were not going to cut it here.

So I used some WS2812B pixel 'rings' from CoolComponents (https://coolcomponents.co.uk/products/1 ... 565e&_ss=r) - I probably should have used the WS2812 breakout boards these are based on and soldered my own wires..

By pulling the metal conductors for the LED out of the switch casing and cutting down the NeoPixel wires to +ve, gnd, data in and data out - the wires 'just' fit past the microswitch housing. The LED board is also a good fit for the switch housing. With a little more cutting of the plastic housing it would be possible to keep all 6 'wires' - however, as I had to cut the connectors off and the +ve and -ve are both just soldered together on the breakout this didn't seem to be necessary.

So now I have multi-colour LED switches (a world first?) - easily programmable using the FC component!

Martin
These users thanked the author mnf for the post:
Benj (Thu Mar 12, 2020 10:39 am)
Rating: 5%