The original code that I started with played a simple five tone tune, the theme from Close Encounters, and lit up the brim of a hat when exposed to light. My goal was to deconstruct the code (and look for patterns) to see if I could play a different tune and change the LED configurations. My tune is nothing but a scale played forwards and backwards; but, after an afternoon of puttering, I was able to get it to work on a couple of different microcontrollers, including the LilyPad.
One thing that I found really interesting about the original code was the way that the loop calls a function embedded within a function (a music function embedded within the light function). I tinkered around with the numerator and denominator in the code for the delayAmount and loopTime, to see how it changed things, but I still don't understand how the original values were derived.
Rather than taking screen shots of code from my computer, I've embedded the code using Codebender, a cloud-based Arduino plugin that makes it easy to share code.
No comments:
Post a Comment