Thursday, February 26, 2015

Day 56 Making with CODE using a Lilypad microprocessor

On Day 55 I described how I created my first flower for my coding garden by hacking a votive LED tea candle and adding to it a beautiful flower made from colored stockings.



Once you have created your  beautiful creation, the next step is to add it to a collaborative garden and learn just enough code to give the flower its own unique presence in our collaborative garden.  I'm working on the premise that 'CREATING" something beautiful will lead to a high motivation to make it come to life.  And since learning some basic coding give your contribution to our collaborative garden the life you want it to have,  maker will have a very personal reason and high motivation to learn to code.   

We all know that motivation is the key to learning, and I truly believe that this collaborative garden will provide girls with higher  motivation to learn to code than writing a program that says "HELLO WOLRD".   But enough philosophy -- let's get started with next steps to creating the garden.

In yesterday's post we hacked our flower, by removing the battery and switch from the votive candle and replacing the LED with a new LED with longer leads, making it more versatile. Today I took the remaining 5 votives in my six-pack and quickly hacked them all (removing the battery and switch and replacing the LED with one with longer traces).  









Now let's play with our new hacked votive candles and see how easy it is to control them with a a microprocessor and a little bit of coding knowledge.



The first step is set up an Arduino board so that it 'talks' to our computer.  I chose the LILYPAD  Arduino board  because it's inexpensive and once you learn some basic coding techniques, you can use it for all types of fun crafty projects.  Installing the drivers the first time  is the trickiest part to using this board, but Sparkfun provides some great directions on how to use a USB cable and FTDI (adapter) to connect the LilyPad to your computer, and set up the Arduino software  so it can talk to your Lilypad.

Once the drivers are installed correctly, you should not have to worry about them again, but you might need to double check that the Arduino settings are still configured for your LilyPad board.  (Check these AFTER the board is connected to your computer).







The next step is to use  alligator clips to connect the positive and negative lead  of one of your newly hacked votive candles.  I like to color code my negative and positive leads.  In this project I chose black and white alligator clips to connect the negative leads.

Take the alligator clip that is connected to the negative lead on your candle and connect it to the negative pin of your LILYPAD.

Then take the alligator clip that is connected to the positive lead on our candle and connect it to any PIN on your LILYPAD (except negative).  I chose PIN 5.









Let's load the sample code called BLINK.  We are going to change the code a bit  by changing PIN 13 in the sample code to PIN 5. (assuming your colored alligator clip is hooked up to Pin 5)







It should now look like this .




You'll want to click on the Verify button to make sure your code works.  This process compiles the code and checks it for syntax errors.  It's easy to accidentally delete a comma or make a syntax error when working with code. Verify is the first step to making sure you have all the "syntax" correct to that the microprocessor (LILYPAD) will understand our instructions.

If no 'orange' error messages appear at the bottom,  you're golden and can now hit the SEND button to send your code (instructions)  to the LILYPAD microprocessor.  You'll see some lights blink quickly on the microprocessor as the instructions are transferred from your computer to the LilyPad's microprocessor.   Then if all worked well your votive candle (the one connected  to your LILYPAD with alligator clips)  should start to blink.

Now blinking might not be all that exciting (YET).  But once you start to understand how code works, you'll be able to add other effects like blink and fade.   And once you can control one flower, you'll be able to apply your new coding skills to control a whole garden full of flowers.  Imagine what you'll be able to do then.


In the next post we'll take a closer look at the code so that we can start doing more than blink a flower.





No comments:

Post a Comment