Comments: Multiplexer Breakout Hookup Guide
Looking for answers to technical questions?
We welcome your comments and suggestions below. However, if you are looking for solutions to technical questions please see our Technical Assistance page.
If you've found an issue with this tutorial content, please send us your feedback!
Hello,
I am trying to understand your code. It has been an extremely long time since I have done any type of embedded development and I am trying to recover lost information from my brain.
What is the "magic" 512 number in your DELAY_TIME definition?
const int DELAY_TIME = ((float)LED_ON_TIME/512.0)*1000;
Thank you,
(You probably won't even see this after 7 years, but I feel compelled to answer...)
It's used to calculate how long the loops which ramp the LED intensity up then down should dwell on a value so that the total time to run both the ramp up and ramp down loops equals LED_ON_TIME, which is set to 500(ms).
The loops iterate over 256 values up, then 256 values down for each LED 'blink', so 512 values total. The LED 'on' time is set to half a second (500ms) - so this is 500 / 512, then multiply this millisecond value by 1000 to get microseconds.
(500 / 512) * 1000 = 976.5625
To loop over 512 values in exactly half a second, each value needs to be shown for 976.5625us.