Adding LED fading to word clock

Posted on
  • Hi, I've had fun recreating and customising the Tiny Word Clock project. However, I'd really like to have the LEDs fade in/out when displaying the time. I've read about using analogueWrite() to do this for individual LEDs but I can't figure out if it's possible to do the same thing with a matrix of LEDs?
    Any *pointers gratefully appreciated! :-)

  • ...the way this is built... not really, because the Graphics buffer is 1 bit deep - off | on (8Wx8Hx1D)

    The graphics buffer is set in outputWords() every minute/

    The graphics buffer is read out as such - 1 bit per pixel or LED or character - totally 64, 8 at a time. This is setup in startScanning() and happens in anonymous function in setInterval(...) - using Charlieplexing. Every 10ms the graphics buffer b (8 bytes) is read out and mapped to the display thru the pins - and that with minimal AND optimized code (pre-bound).

    The brightness is defined by how long it takes to run the code for each single LED and the break until it may be lit again. And this is done 100 times a second or every 10 milliseconds.

    You may try with an analog write on one set of the pins - Anodes or Cathodes... Since for some function they are concatenated (in function c()), you have to take them apart and always drive them separately. Then I'm not sure if all pins you want to drive analog, they actually can do that because - first - they have to be able to do pwm, and - second - have to be able to do it fast enough - and you have to change the duty cycle to control the brightness... and this for 'outgoing' and 'incoming' words (only) in the few seconds around the minute change.

    Read is done in less than 10ms and optimized to give a steady feel and still have cycles left to do the other things... if these other things take too long, then the brightness starts to flicker...

    To give a feel for the time it takes, time 16 analog writes - 8 from a table with the values for the duty cycle and 8 with 0 duty cycle. This allows the changing of the sourcing or sinking - for all LEDs at the same time. I'm sure that 128 analog writes take too much time - but would allow each individual LED have it's own brightness... You would use a 8x8x8 matrix where you map the 8 bits per pixel to a duty cycle for 64 writes, and 0 duty cycle for the other 64 - one of both writes for each of the led... it may take too long and thus become too dim.

    You may give it a try...

    Since you cannot shorten the on-time, it is give to get every row (or col) on and off) - an other option is to slow down the scan scan rate... but at one pint it become flickery... and it makes all words to got dim and come back with some of the old and some of the new ones. Instead of setInterval() you make the anonymous function a named function and self-invoking with setTimeout() where you control the timeout time around the minute change.... that's probably the easiest... Since values / brightness are not linear, you need to empirically find what's optimal.

    I could give it a try using mu 3x5 LED matrix as used in conversation about Driving LED matrix with shift registers such as 74HC595 - direct driven though without shift registers (the 3x5 - for one numeric digit - comes from the fact that I could drive this 3.5+ decades ago using a single 8 bit I/O on 8 bit Microprocessor 8085 with 3 outputs, one for each column... at 2.54 MHz... processor clock... :\ )

  • Just to add it's not quite Charlieplexing - just standard multiplexing.

    As @allObjects says analogWrite is unlikely to work, but you can slow down the update rate, which will in turn dim the whole image.

    startScanning actually returns the 'interval number', so if you change the line startScanning(); to scanInterval = startScanning(); then you can then use changeInterval(scanInterval, X); to change the brightness.

    Having X as 10 is the default (100Hz), but you could slowly change it to 100 (which will start to look a bit flickery, but which will be 1/10th of the brightness).

  • Thanks both very much for the replies! I have a few other tweaks to do then will take a look at the LED fading again.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Adding LED fading to word clock

Posted by Avatar for user100018 @user100018