I'm teaching a course this semester on technology in libraries, and this year there will be a making / coding assignment using the LilyPad Arduino. This will be an inquiry-based, open-ended, learn-as-you-go assignment. I had never used an Arduino before, nor had I coded in anything other than HTML, before getting my LilyPad kit in the mail a week ago. Since I have a 2-year-old at home, I decided to make a toy with my LilyPad. This is basically a round, two-page, vertical "book" that plays "Twinkle, Twinkle" and blinks white LEDs when the night side is exposed, and plays "You Are My Sunshine" and blinks colored LEDs when the "page" is turned to reveal the day side. To see the toy in action, visit http://www.youtube.com/watch?v=EQ-e5EcD8rU or download the video file below.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Materials
- Scraps of non-stretchy fabric, such as felt or quilting cotton (you will need at least 3 pieces that are at least 12"x12")
- Approximately 2 sq. feet fusible fleece (Pellon) or fusible web
- Approximately 1 sq. ft. fusible adhesive (such as Heat 'n' Bond)
- Embroidery floss (I used black, white, yellow, and orange)
- Sewing needle
- Glue-on eyes (2 large for owl, 2 small for birds)
- Fabric glue
- (Optional) 2 green gems for leaves on "day" side
- (Optional) Embroidery hoop (makes stitching easier)
- LilyPad Arduino Simple board - https://www.sparkfun.com/products/10274
- 6 white LilyPad LEDs - http://www.sparkfun.com/products/10081
- 3 colored LilyPad LEDs (I used three from the "rainbow" set, https://www.sparkfun.com/products/11842)
- Li-Po battery - https://www.sparkfun.com/products/731
- Conductive thread - https://www.sparkfun.com/products/10867
- LilyPad light sensor - http://www.sparkfun.com/products/8464
- LilyPad FTDI basic - http://www.sparkfun.com/products/10275
- Mini-USB cable
- FTDI driver (http://arduino.cc/en/main/software) and Arduino IDE (http://arduino.cc/en/main/software) should be installed on your computer
Step 2: Plan
- Sketch your day and night panels. Include locations for all electronic components. The light sensor should be placed on the front of the night panel, above the midline. See the pictures for my sketches.
- Plan your stitching. Your stitches with the conductive thread will be made through the back layer of fabric only (with the exception of stitches that hold electronic components in place on the front of your project). Remember not to cross stitches. My stitching guide is shown in the picture above.
Step 3: Piece Together and Embroider Day and Night Panels
- Cut out two 12-inch circles: one blue (for the day panel), and one black (for the night panel).
- Using scrap fabric, cut out shapes. On the night panel, you will need to cut out six stars, a crescent moon, a branch, and the owl's body, wings, feet, and nose. On the day panel, you will need to cut out a yellow circle for the sun, a butterfly, a branch, three flowers, and bodies, tail feathers, chest pieces, wings, and beaks for the birds.
- For any fabric that might fray along the edges, apply a thin bead of Fray-Check along all edges and allow to dry. You won't need this for fabrics like felt or fleece.
- Lay out all of your shapes on your circles. Make sure that after you fuse / sew everything down, your electronic components will be in roughly the same places as in your planning diagrams.
- Once everything is in place, use the fusible adhesive with your iron to stick your pieces to the panels. Note, you do NOT want to stick or sew down the stars on the night panel or the centers of the three flowers on the day panel, since you will be sewing LEDs here later. You should also wait to glue down the eyes.
- Using your embroidery floss and a needle, embroider along all edges and add sun rays and butterfly antennae. For most edges, 2-3 strands of embroidery floss is sufficient. I mostly used the blanket stitch, but you can use any stitch you think looks nice. Here's a great tutorial on five basic embroidery stitches, including the blanket stitch: http://www.craftstylish.com/item/8312/how-to-five-...
Step 4: Sew
- Cut out one 12-inch circle and one half-circle from your fusible fleece / fusible web. This layer is technically optional, but will make your toy soft, like a quilt, and will help to give the toy more structure, which in turn will help keep your conductive stitches from rubbing against each other.
- Cut out one 12-inch circle of backing fabric. This can be any color you choose (mine was black).
- Place the night circle right-side-up on a flat surface. Then place the day circle right-side down on top of the night circle (right sides together), with the bottom of the day circle meeting the top of the night circle. In other words, the two panels should be right-sides together, but upside down from each other. Finally, lay your half-circle of fusible fleece over the top half of the day panel (the half with the sun). Pin around the edges to hold everything in place, then sew the outside edge of the half with the fleece, leaving a 1/4" seam allowance. Do not sew the other half. Turn right-side out and iron to fuse the three layers together.
- At this point, you should have one finished half-circle with two raw half-circles sticking out. Now, lay down your backing fabric circle on a flat surface, right-side up. Then, lay down the two raw panels of your project right-side down on top of the backing fabric. Your finished half-circle will be inside; you can squash it a bit to keep it away from the edges. Finally, lay your 12-inch circle of fusible fleece on top. Make sure everything is lined up, then pin around the edges to hold everything in place and carefully sew around the edge, leaving a 1/4" seam allowance and stopping about 3 inches before you complete the circle. Be sure you don't accidentally sew into your finished half-circle.
- Using the 3-inch unsewed section, turn the project right-side out. The fusible fleece should be the middle layer. Iron to fuse all your layers together, then turn in the remaining unsewed edges and use your needle and thread to close up the 3-inch section.
- Glue on the owl and bird eyes.
Step 5: Sew Your Conductive Stitches
- First, place your LilyPad board in the bottom right corner of the backing fabric. If you're viewing your project from the front, this would correspond roughly to behind the large bird's feet. You can use some double-sided tape to hold the board in place while you make your first few stitches.
- Place your buzzer to the upper left of the LilyPad board (+ on the left). Using conductive thread, make several passes through the positive pin of the buzzer, being sure to only pass through the backing fabric (you don't want your stitches to show up on the front of your project). Then make a neat stitching line to Pin 6 of the LilyPad board, and make several passes through that pin, again going only through the backing fabric. Do the same thing from the negative pin of the buzzer to Pin 5 of the LilyPad.
- Next, place your light sensor on the front of the night panel, above the midline and just to the left of the moon. The "S" pin should be at the bottom. Using your stitch diagram and the same method described in the previous step, sew the negative pin of the sensor to the negative pin of the LilyPad board, the "S" pin to A5, and the positive pin to A4.
- Place the colored LEDs on the front of the "day" panel at the center of each flower (you can use double-sided tape to hold them down temporarily; just remove it when you're ready to sew). Sew the positive pins of these LEDs to pins 9, 10, and 11 as shown in the stitching diagram.
- Place all of the white LEDs on the front of the night panel. Using a very long piece of thread, stitch through all of the positive connections on these LEDs and around the bottom edge of your project to pin A2, using the stitch diagram as a guide.
- Using another very long piece of thread, stitch through all of the negative pins of all LEDs, ending at Pin 5 as shown in the stitch diagram.
Step 6: Program
Disclaimer: I have never coded in anything other than HTML before, so I'm sure that people who know better will look at this code and think it's terribly inelegant. However, it does work!
Here's the behavior I wanted: When I turn the toy on, I wanted it to read the light sensor. If it's light, that means the sensor is exposed, which means the "night" panel is showing. In that case, I wanted it to play "Twinkle, Twinkle" and blink the white LEDs. If it's dark, the flap is up and the sensor is covered, so the day side is showing. In that case I wanted it to play "You Are My Sunshine" and independently blink the three colored LEDs. That much was pretty easy to code, but what I really wanted was for the song and light display to change immediately as soon as I flipped the toy, and figuring out how to code that was difficult (for me... I'm sure it would be easy for others). But I did eventually figure it out, basically by having it test the light value after each note of the song and restart the loop if the light value had risen above or fallen below the threshhold (depending on which song it was switching from).
I realized in doing this project that it may have been easier to do this with an accelerometer, and that wouldn't have the issue of not being usable in a dark room. However, since this is meant to be a toy for a child, an accelerometer probably wouldn't work (kids like to shake toys). So all things considered, I think I would stick with the light sensor if I did this again.
My code is attached in the text file below. I tried to provide comments to describe what I was doing with each line of code.
Step 7: Upload Your Program and Test
- Plug the Li-Po battery into the LilyPad board. The battery will charge when you have the board connected to your computer (you should see an orange light if it's charging; if you don't see an orange light, turn the switch on the board to "on").
- Attach the FTDI breakout board to your LilyPad and use the mini USB to connect the board to your computer.
- Using the Arduino IDE, input your code and upload to your board. Your toy should be fully functional at this point!
Step 8: Finishing Touches
At this point, you can glue or stitch on your white stars and the flower centers to mostly cover up your LEDs. I cut a tiny hole in the center of each of these pieces so as not to cover up the LED itself, and just used glue to stick them down.
I also cut a quarter-sized circle of black fabric out to cover up the light sensor because I didn't like how obvious it was on the night panel (I cut out a hole in the middle so the sensor could still read). I glued this around the sensor.
I put a drop of fabric glue on each knot on the back of my project, to make sure that none of my stitches unravel.
Finally, I decided that I wanted something to cover up the LilyPad and my stitches, and to protect them from rubbing against each other. So I cut another 12-inch circle out of stiff felt, and used small (1/2" square) pieces of Velcro (glued down) to attach this to the back of my project.