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

Post Reply
mnf
Valued Contributor
Valued Contributor
Posts: 1208
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 440 times

WS2812 LED Flexible 32 x 8 grid

Post by mnf »

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.05 KiB) Downloaded 548 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

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

Re: WS2812 LED Flexible 32 x 8 grid

Post by Benj »

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.

mnf
Valued Contributor
Valued Contributor
Posts: 1208
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 440 times

Re: WS2812 LED Flexible 32 x 8 grid

Post by mnf »

Hi Ben,

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

Martin

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

Re: WS2812 LED Flexible 32 x 8 grid

Post by Benj »

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.

mnf
Valued Contributor
Valued Contributor
Posts: 1208
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 440 times

Re: WS2812 LED Flexible 32 x 8 grid

Post by mnf »

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 462 times
LightBoard.fcfx
(51.72 KiB) Downloaded 511 times
(Just testing a (low res) sinewave scroll)

Martin

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

Re: WS2812 LED Flexible 32 x 8 grid

Post by Benj »

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.

mnf
Valued Contributor
Valued Contributor
Posts: 1208
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 440 times

Re: WS2812 LED Flexible 32 x 8 grid

Post by mnf »

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

mnf
Valued Contributor
Valued Contributor
Posts: 1208
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 440 times

Re: WS2812 LED Flexible 32 x 8 grid

Post by mnf »

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

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

Re: WS2812 LED Flexible 32 x 8 grid

Post by Benj »

Hi Martin,

Nice video, looking very good.

You inspired me to put up a video of mine.

https://youtu.be/r-BFg3YauG0

mnf
Valued Contributor
Valued Contributor
Posts: 1208
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 440 times

Re: WS2812 LED Flexible 32 x 8 grid

Post by mnf »

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.

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

Re: WS2812 LED Flexible 32 x 8 grid

Post by Benj »

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 21842 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.

viktor_au
Posts: 362
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 45 times
Been thanked: 62 times
Contact:

Re: WS2812 LED Flexible 32 x 8 grid

Post by viktor_au »

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: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: WS2812 LED Flexible 32 x 8 grid

Post by Benj »

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/

viktor_au
Posts: 362
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 45 times
Been thanked: 62 times
Contact:

Re: WS2812 LED Flexible 32 x 8 grid

Post by viktor_au »

Thank you for sharing this project Ben.

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

Re: WS2812 LED Flexible 32 x 8 grid

Post by Benj »

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: 1208
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 440 times

Re: WS2812 LED Flexible 32 x 8 grid

Post by mnf »

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

chad
Posts: 198
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 27 times
Been thanked: 33 times

Re: WS2812 LED Flexible 32 x 8 grid

Post by chad »

I know this is a little late but.. That Is a neat little hack. I have some of those same push buttons.

I would love to see a port of http://fastled.io/ for flowcode. When I was playing with the ws2812 and the Arduino I tried every lib and this was my favorite. IT has a cool demo that shows off what it can do.

Chad

and yeah the 2x2 apa102s are really tiny.

mnf
Valued Contributor
Valued Contributor
Posts: 1208
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 440 times

Re: WS2812 LED Flexible 32 x 8 grid

Post by mnf »

Hi Chad,

It gives a very good effect - the buttons look great... Just not been able to put them to much use in the current climate - but their day will come.

I haven't used the fastled library - but I'll give it a try. Mostly now I'm using 'bitmaps' stored in i2c memory (24lc256) with the display above (I use a 256 color lookup table to reduce memory usage - and I think 16 colours would be okay too(I don't think my eyes can discern more) - my code allows a scroll of any size bitmap into the display (read the next 8 bytes, scroll left and write the end column) - unfortunately my 'artistic' skills are limited to the most basic of images :-(

Martin

Post Reply