Monday, October 10, 2016

Playing with LilyPad Arduino: Week 5 Reflection

This week, those in my class who are new to coding were challenged to set up the Arduino IDE on their computers and make LEDs blink, using an LilyPad Arduino.  While I'm not an expert coder by any stretch of the imagination, I am not new to the LilyPad.  As a result, I was invited to challenge myself.  With the leeway to do something that would benefit my learning, I decided to play around with some Adafruit code written for the Gemma, pairing music with individually addressable (color changing) NeoPixels.  My first experience playing with tones on a LilyPad took place two years ago, while following the tutorials in Sew Electric.  Since I hadn't yet attempted to pair music with NeoPixels (or NeoPixels with the LilyPad) this seemed like an appropriate and interesting challenge.

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