I have been investigating the BAM method of LED dimming. There are already many microcontroller programs written to control a LED or multiple LEDs with BAM, however I wanted to fully understand the method so I threw together some SPIN code to prove it would work. Click the Read more link for details on the code. This is the main output loop. It reads the variable "bam" and turns the output (pin 16) on if that bit of the variable is a 1. It repeats each bit of the variable a different number of times to keep the output on longer for the bits that represent a larger number. By doing so it can keep the LED an practically any brightness level. Since the propeller has multiple cogs this loop can run in a cog completely separate from the code that will calculate what value the variable needs to be to provide the proper output. In order to test the main loop I created a simple fade in and out sequence that slowly turns the LED on, and then turns the LED off in a slightly faster manner. You can download the code below.
0 Comments
Leave a Reply. |
AuthorJon owner AboutThis blog covers a multitude of up and coming technology, as well as how to guides, tips and tricks, and other interesting technology related items.
Archives
January 2016
Categories
All
|