The goal of this project is to get anyone to write a program in less than a minute by encouraging students to customize the animation for a nightlight. The basic outline of this project:

  • Used an Arduino microcontroller + LED to demonstrate an immediate feedback loop (our demo used the Adafruit Flora v2 because of easy uploading via USB + an onboard LED to remove the need for soldering).
  • Stripped down code to be very approachable. 
  • Placed the microcontroller + LED in an attractive case, to make the outcome look more polished and approachable
  • Provided simple instructions to be placed next to the computer so that the student can easily reference the colors and available patterns. 

While it's possible to do this project without hands-on instruction, we did find that explaining the project with a voice over helped increase student confidence. Positioning this as "playing" or "customizing" as nightlight vs. "coding" or "programming" a nightlight encouraged more students to give it a shot. (See my Maker Faire post for more details about how this demo can be used.)

To replicate this demo yourself, please follow the steps below. These instructions are up-to-date as of May 2016. Similar instructions can be used with other microcontroller+LED combos, but the code would also need to be customized for your choice of microcontroller. 


Create the Nightlight

To create the nightlight, you'll need:

  • An Adafruit Flora v2 board - Arduino compatible + onboard RGB LED
  • A casing for the nightlight. Instructions for how to build ours below, but you could do your own custom casing:
    • .25 inch MDF board
    • A lasercutter
    • Illustrator files for cutting the nightlight (2 top pieces, and the sides)
    • E6000 adhesive, or something to glue the panels together
    • Transfer paper or some other opaque paper to glue to the insides of the nightlight cutouts
  • A USB cord for connecting the Flora to your computer


Preparing your computer

The Flora runs on the Arduino platform, so here are some step-by-step instructions about how to get it all up and running:

  • Download and install the Arduino IDE 
  • Configure Adafruit Flora and Neopixel Libraries and Boards

    • Under "Preferences" --> Additional Boards Manager URLs, copy and paste:

    • Go to “Sketch” → Include Library → Manage Libraries, and search for and Install:

      • Adafruit Flora Pixel Library

      • Adafruit NeoPixel Library

    • Go to “Tools” → Board → Board Manager, and install Adafruit AVR Boards


Connecting your computer to the Flora and uploading code

Plug the Flora into your computer using a USB cord. From here, you'll need to do a couple more things to ensure you can upload code from your computer to the Flora microcontroller:

  • Open a new sketch ("File" --> New), and copy and paste our source code into the sketch, and "Save"
  • Then configure the IDE to send the code to your Flora:
    • "Tools" → Board → Select "Adafruit Flora"

    • "Tools" → Programmer → Select "AVR ISP"

    • "Tools" → Port → Select the one that has “(Adafruit Flora)” in the title

  • Test uploading your code to the Flora by pressing the Upload button in the upper right hand corner


Setting up the demo

Before presenting the nightlight to students, we suggest you do the following:

  • Print out our student instructions (Page 1, Page 2), and place them right next to the computer
  • Open the code file and full-screen the window to reduce distraction
  • Scroll the code so that the loop() function is the only part of the code visible in the screen (there should be enough whitespace above and below to hide the scary stuff).

Then invite students to play with their nightlight! We found that giving a voice over of the printed instructions helped build confidence. 

We did notice a couple common errors:

  • Students forgetting to properly capitalize the function names or end lines with ;s
  • Students accidentally deleting the closing } in the loop function. 
  • Students including too many colors per function name. We encouraged them to think how they could use the iterative nature of the loop function to achieve the same result with multiple function calls. 

Best of luck! Let us know if you try this out and let us know how it goes!

Note: Credit to GeometricInk on Etsy for the image on the nightlights. I used her art here as a reference and translated to a lasercut file, and hope it's okay since this is all not-for-profit.