Wednesday, October 29, 2014

Halloween with Arduino


Arduino Halloween from Duxbury Free Library on Vimeo.


It wasn't easy but we were able to accomplish our 2 Halloween projects: an LED pumpkin and a talking motion sensor skull.  I'll go over each and things that we learned (aka what they sometimes to forget to tell you in the directions). Special thanks to Kevin Osborn for coming down to provide his expertise for the skull.  Also worth noting, Lynda.com also has great tutorials for beginner Arduino. This subscription is offered free of charge in our library and also if you are a librarian through the MBLC.

We started with the hardest one first, THE TALKING SKULL (Advanced)
*If you are just starting out I suggest doing the entire SIK CODE GUIDE book (comes with the Sparkfun Inventor's Kit) and if you're not ready to throw it out the window then try the Pumpkin*

Items required:
PIR Motion Sensor   $9.95
Sparkfun Inventors Kit  $99.95
Sparkfun MP3 Shield  $39.95
microsd card and micro SD reader (to put mp3s on it from computer) $18.99
Soldering gun
skull  $8.99
9v battery and 9V Barrel Jack Adapter (to run the program without the computer) $2.95
speakers or headphones
mp3 sound
PATIENCE
GOOD GLASSES/MAGNIFYING GLASS

MP3 SHIELD


VIEW OF MP3 SHIELD. THIS SITS DIRECTLY ON TOP OF THE ARDUINO (with 9V Jack of Arduino and speaker jack of the shield aligned)


Wire Connections:
BLUE WIRE-5V ON SHIELD TO + POSITIVE ON BREADBOARD

LIGHT BLUE (some might call it green)-GROUND ON SHIELD TO -GROUND ON BREADBOARD

PR SENSOR WHITE TO ANALOG 0 ON SHIELD  (All analog outputs are free)

PR SENSOR BLACK TO GROUND ON BREADBOARD

PR SENSOR RED TO + POSITIVE ON BREADBOARD




AV SERVO WHITE TO DIGITAL PIN 10 ON SHIELD (This pin isn't being used by the MP3 shield but some are so you have to see the Sparkfun online tutorial if you want to hook up a button or LED)

AV SERVO RED TO + ON BREADBOARD

AV SERVO BLACK TO GROUND ON BREADBOARD

PR SENSOR WIRE HOOKUP
Here's a dropbox link to our code: Hallowscream with 2 mp3s to try. Kevin O. wrote this using a modified code of his INSTANT PARTY.

It also comes with a button and LED coding that we didn't use. This way you would have to press the button before you activated the motion sensor.

If you hook this up the same way we did, and use the code. It will work. Make sure to name your mp3 tracks track001.mp3, track002.mp3 and so on.

I recorded my Happy Halloween in Garageband for MAC (use Audacity for PC) but there are plenty of free sites to download spooky sounds.


Things we learned:

You have to solder the header pins onto the mp3 shield. This is a one time thing but it is a must for the connections to work properly. Be careful when putting the headers in because a pin could get bent easily.

The PR Sensor's wires don't match standard protocol. red= positive White=ground, black= input. We changed the wire colors during hookup so it matched standard red= +, black= ground, white=input.

It is really hard to program multiple outputs (ie: servo motor, motion sensor, LEDs) and getting them all to work in relation to each other without a solid knowledge of arduino coding. It's like a deep rabbit hole where many things can go wrong.  Also not every code is equal, some people write great side notes in their code so it's easy to change things up, some don't.



LED PUMPKIN (EASIER)

Items required:
Sparkfun inventor's kit $99.95
SIK Code Guide Project 4 (included in kit)
Pumpkin $1.00
drill
large LEDs
9v battery and 9V Barrel Jack Adapter (to run the program without the computer) $2.95
 extra wire
electrical tape

Rather than hooking up the LEDs directly to the breadboard (see traditional instructions below where yellow circles indicate the LED placement)
ORIGINAL DIAGRAM


I cut some wires and stripped the rubber off inserting one end of the positive (RED) and negative (BLACK) wire to match the yellow positive and negative circles indicated {ONE WIRE C3 (+RED), C4(-BLACK) to PUMPKIN LED, NEXT WIRE C5 (+) C6 (-) to PUMPKIN LED and so on} . The other side of the wire was brought to the pumpkin and connected to the the positive and negative leads of the LEDs (remember the positive lead on the LED is longer than the negative) Think of it like an extension cord so the LEDs could be moved to the pumpkin and still powered by the breadboard.

INSIDE THE PUMPKIN


This project will allow up to 8 LEDs. I didn't need to put all the resistors and wires in place since I only used 5 LEDs but it was nice to have the option to pick and choose where to put the extension wires on the breadboard. It tended to get hairy in there. If there is no wire, nothing lights and no code needs to be changed. (The less code changing THE BETTER).

Just remember where you put your extension wires affects the order of the lights. C3's Wire being first LED in the order to blink.

Highlighted Yellow was wire connections rather than LEDs. White circles indicated placement on breadboard. 





BOARD HOOKUPS

The Arduino has been the hardest thing we have done yet in STEM. It's important to truly understand the projects in the book that comes with the Sparkfun Inventor's Kit (SIK CODE GUIDE) and experiment with code that gives copious notes on each part before trying an off book project. 

1 comment:

  1. You are the BOMB.
    I hope you reailze how empowering this is....!

    ReplyDelete

Thanks for commenting!