Monday, 13 April 2015

Failure Is Always An Option

Struggling at something is the first step toward being really good at it.  It's a hard concept to get your head around while it's happening, after all failing at something can be a harsh experience.  On the other hand, once you've corrected your mistakes, you're less likely to make them again.

Case in point: my recent experience learning to program an Arduino Lilypad.  I followed the instructions in this tutorial by Sparkfun, attaching 9 LEDs to the board, and completing the circuit by connecting the negative ends of the LEDs.  I plugged the board into my computer and tried to program it using the code (called a sketch) provided in the tutorial:



The sketch uploaded without a hitch, but nothing happened.  I was at the hackerspace at the time, but nobody could quite work out what had gone wrong, and it was getting late.

With a bit of help, I soon figured out what had gone wrong.  I hadn't had enough sewable LEDs for the Sparkfun tutorial, so I used some others that my partner had bought for another project and never used.  But the LEDs I used were NeoPixels from Adafruit, which work a little differently.  The LEDs required for the tutorial have the usual positive and negative terminals that all electronic components have:


In addition to these, NeoPixels also have data terminals (the ones marked with the arrows):


The data line allows NeoPixels to be chained together, which creates some very cool effects.  On the other hand, they require a completely different wiring configuration to normal LEDs.

But not to worry, with a bit of guidance and research I rewired my LEDs.  I made a couple of mistakes along the way, including attaching my data line to an analogue port rather than a digital port.  I also got confused about the labelling and numbering of the pins on the Lilypad board, which differ wildly between manufacturers, and are used in the sketch to determine what each LED does and when.  I was shown how to look up what each pin does using a pinout, which helped immensely.

And I got there in the end!  I used this tutorial from Adafruit and one of the example NeoPixel sketches provided.  Here are some of the results:







Ultimately I learned a lot from my mistakes, and now I feel like I know a bit about how things work, rather than just following instructions.  Here are the lessons I learned:
  • How to use different kinds of LEDs
  • The difference between digital and analogue pins on an Arduino board
  • How to look up and interpret pinout diagrams
  • How to make sure the Arduino IDE is properly configured for the board and com ports
  • Basic manipulation of code in the Arduino IDE
I look forward to using my new-found knowledge to start improvising, and to inspire future projects.