Introduction: Automated Halloween Treat Dispenser - Powered by Intel Edison

About: Born as a farmer, studied electronics ,working as a Consultant and a 3D printing enthusiast by night..

It's almost that time of year again! If you have just started planning your Halloween decor , here is an automated Halloween Treat dispenser which you can make, with the following features as shown in the video above

  • Treats dispensed when a trick-or-treaters is detected using a Ultrasonic Sensor connected to the Intel Edison
  • A spooky skeleton connected with servo's and LEDs to monitor the Treat basket
  • And a speaker that play pre-recorded spooky sounds
  • In addition, if you have a GoPro at home you can connect it to the Intel Edison's WiFi to take picture or time-laspe of the trick-or-treaters collected their treats.

Step 1: Buying Treats and Collecting the Components

Buy treats that are kind of small, and that are kind of easy to roll when placed on a slanting table, this will be helpful for the smooth following dispenser as shown in the video in the introduction.

In addition add a some kind of a prop to your dispenser , I choose a skeleton as shown in the picture above.

You'll need the following electronic components

Tools you'll need

  • Hot glue gun and sticks
  • Xacto knife/Blade
  • Halloween decoration and something to mount the dispenser

Optional

  • GoPro - using the GoPro, so that the Intel Edison can connect to the GoPro Wifi

Step 2: Cutting the Skelton to Attach the Servo's

Cut open the the back of the skeleton as shown in the picture above using an xacto kinfe or a blade

Then cut the hands and using the long servo arm cut open the arm and see that you are able to rotate it freely.

Finally cut the head , here you may have to shorten the neck depending on your skeleton for the servo to fit.

Step 3: Hotglue the Servos to the Skeleton

Hot glue the servo's to the skeleton or a prop that your choice.

Here I hot glued 3 servos as shown in the picture above, you may need to cut out the shoulder portion of the skeleton using the xacto knife.

Now hot glue the the servo arms to the hands and head.

And finally check that the arms and the head is freely rotating on the servo.

Step 4: Mounting the Proto Shield on the Edison and Building the Circuit

No build the Circuit as shown in the picture above

Snap the Intel Edison on the Arduino break out

Insert the Proto shield on the Arduino headers of the Intel Edison base board and make the following connections

  • Connect the 2 Red Leds to pin number 12 and 13 on the Proto shield, using 220 ohms resistors
  • Button is connected to 10 , this will be replaced by the ultrasonic sensor connected to pin 2 after testing is complete
  • Connect the RGB Led pins to pins 7,8 and 9 using 220 ohms resistors
  • Now connect the 3 servors to
    • Servo the head to pin 3
    • Right Arm servo to pin 5
    • And left Arm servo to pin 6

Step 5: Adding Servo the Dispenser and Testing the Circuit

Now to create the dispenser, measure you treats approximately and cut a hole thrown the bucket as shown in the pictures above

Hot glue and screw the servo at the opening.

Using a paper plate cut out piece slightly larger that the piece you cut out from the treat bucket.

Use hot glue to attach the Servo Arm.

Connect the Servo to pin 9 on the proto shield

Step 6: Uploading the Arduino Code and Testing

Download the latest version of the Arudino software from the URL

Once you have the Arduino software open ,search for Intel in the board manager. And add Intel Edison board as shown in the picture above.

Download the code attached to this step.

In the tools menu, select the board as Intel Edison and port to which the Edison is connected as shown in the picture above and hit the upload button as shown in the picture above.

You should see the RGB LED cycle through and when you press the button which added for testing(which will be replaced by the ultrasonic sensor in a future step) you should see the treats dispensed out as shown in the Video above.

Step 7: Downloading the Yacto Image Onto the Edison

Follow the link below and download the latest version of Yocto image to your Mac.

https://software.intel.com/en-us/iot/hardware/edis...

Note : In my case the name of the zip file downloaded is edison-image-ww05-15.zip, this could change based on when you are going through this instructable.

Now connect the micro USB cable to the USB port which is closer to the switch, as shown in the picture above.
And connect the other end of the USB cable to your Mac, once this is done you should see a Edison drive in the left of your Finder window. (this is similar to when you connect a flash drive or an external hardisk to your Mac)

.If you click on the drive it should be empty.unzip the file into the Edison Drive Click on the Edison drive to validate that the files for the Yocto images are copied as shown in the third screenshot above.

Click on the Eject button in the Finder window which is at the side of the Edison disk.

Step 8: Connecting to the Edison and Then Upload Wav Files Via FTP

Disconnect the USB cable and connect the USB cable as shown in the picture above,

basically connect the lower most USB port to the cable that will be connected to your computer. This is the Serial over USB port.

And connect another micro USB cable to the port which is closer to the switch. In this scenario this port will be used to power up the Intel Edison and the expansion board.

Now on your Mac open the Terminal App
Type in the following command

ls /dev/tty.*

Validate to check if you see something similar to /dev/tty.usbserial-AXXXXXXX as shown in the image above, in my case it is /dev/tty.usbserial-A402IDIL. Note: If your device is not in the list, verify that your board is powered up and check your connection as shown in the previous step

To get into the Edison via the Serial port use the following command screen/dev/tty.usbserial-A and then hit the Tab key, this will populate the complete device name then type 115200 –L , in my case screen command is

screen /dev/tty.usbserial-AJ035QPS 115200 –L

After typing in the command hit Enter twice

Enter root as the user and when it prompts for password hit Enter

Now at the Edison prompt to complete the flashing process type

reboot ota

Note : Here this command will erase everything on your Edison including configuration settings

Now if you want the feature of SSH and FTP into the Edison setup the Wifi at the edison prompt

configure_edison --wifi 


It takes about 10 seconds for the Edison to scan for Wifi networks and list them as shown in the screen shot above. Type the number which matches with you WiFi router name , in my case "androidpod" is my network name which corresponds to 20 in the list Type in your password, and once done make a note IP address and web url which in my case is http://edisonhub.local/.

In addition you will have to also setup the password for root , use the following commands

configure_edison --password

At the prompt type in the new password and type it again to confirm as shown in the image above.

Now you can SSH from another terminal window using

ssh root@ipaddress of the edison

in my case - ssh root@192.168.0.16

You can also a use a tool/software likeFilezilla to transfer file to and from the Edison, here setup the new site in the site manger as shown in the last picture above.

Step 9: Installing ALSA-- Used to Play Sound Via the Sound Card

To play sound from your Edison you will need to install alsa-utils, start of by updating the package manager using the command

opkg update

Configure opkg repository using

vi /etc/opkg/base-feeds.conf

and then add the following lines to the file and save using :wq!

src all     <a href="http://iotdk.intel.com/repos/1.1/iotdk/all"> http://iotdk.intel.com/repos/1.1/iotdk/all</a><br>src x86 <a href="http://iotdk.intel.com/repos/1.1/iotdk/x86"> http://iotdk.intel.com/repos/1.1/iotdk/x86</a>
src i586    <a href="http://iotdk.intel.com/repos/1.1/iotdk/i586"> http://iotdk.intel.com/repos/1.1/iotdk/i586</a>

then to install ALSA use the following command

opkg install alsa-utils

Once done connect the USB sound card and speaker to USB on Intel Arduino board, then give the following commands as shown in the second and third screen shots above

lsusb

you should see something on the lines of an Audio controller , and then type

aplay -Ll

Here make a note of the detail after card 1: , which in my case is device, marked in the green box in the screen shot above.

Now modify the asound.conf file using

vi /etc/asound.conf

And add the following line

pcm.!default sysdefault:Device

to increase Volume of the speaker use the following command

alsamixer 

And to test and play a sound track

aplay /usr/share/sounds/alsa/Front_Center.wav

For more details refer to AlexT's blog at - http://alextgalileo.altervista.org/blog/lets-make-...

Step 10: Testing Playing Sound Using a Simple Button Press Circuit

Now to test triggering of the sound using a button press lets create a quick circuit to test this our.

This is a simple circuit with a button connected to pin 2 and LED connected to pin 3 to indicate that a button is pressed.

Power the Edison using a DC wall adapter , and connect the cable to your computer/mac to upload the Arduino code,here the switch should be closer to the USB cable

Download the ino file attached and upload it to the Arduino

Once done , flip the switch again , you should see your sound card now light up.

Click the button and you should hear sound as shown in the video above.

Step 11: (Optional)Connecting Edison to GoPro's Wifi

This is an Optional step,if you have a GoPro at home, you can connect the GoPro WiFi to the Edison , so that you can automate taking a picture when a trick-or-treater is in the vicinity.

For the circuit , we will use the same circuit we used in the previous step to test playing sounds using ALSA ie button connected to pin 2 and LED connected to pin 3 to indicate that a button is pressed.

To connect to the GoPro WiFi, use the screen command

screen /dev/tty.usbserial-AJ035QPS 115200 –L

once you enter your user name and password of your Edison, turn your GoPro and WiFi on the GoPro on.

Now use the following command to connect to the GoPro WiFi as shown in the screen shot above

configure_edison --wifi

Enter the GoPro and use the curl command to test taking a picture from the Edison terminal, which will use as part of the Arduino code to trigger it once the ultrasonic sensor detect the trick-or-treater.

curl --request GET 'http://10.5.5.9/bacpac/SH?t=XXXXX&p=%01'

The XXXXX in the command above is your GoPro WiFi password.

For more details refer the GitHub repo at https://github.com/KonradIT/goprowifihack/blob/mas...

Here are few more commands that you can include as part of your code

To put the GoPro ON/OFF use

OFF

curl --request GET 'http://10.5.5.9/bacpac/PW?t=XXXXX&p=%00'

ON

curl --request GET 'http://10.5.5.9/bacpac/PW?t=XXXXX&p=%01'

Ensure/putting the camera in photo mode

curl --request GET 'http://10.5.5.9/camera/CM?t=XXXXX&p=%01'

Step 12: (Optional) Taking Picture With GoPro - Test Circuit

Download the Arduino code attached, and modify the curl command to include your WiFi password of you GoPro.

Upload the test code and you should see your GoPro taking pictures as shown in the video above.

Step 13: Putting It All Together

To put it all together start of by making holes for the LED's in the skull and super glue the LEDs after attaching them to bread boarding wire.

Make a hole at the abdomen and insert the Maxbotix ultrasonic sensor and connect this pin 2 on the proto shield.

Place the Edison in an enclosure, in my case I found the Edison with the proto shield to nicely fit in a yorgut container.

Attach the hands with servo arms to the servo and secure them with screws.

And finally use multi-purpose ties and a decor cloth to cover up the circuitry and the base.

Step 14: Uploading the Final Arduino Code

Power up the Edison from a wall outlet .And then download the Code attached and upload it to the Edison,using the Arduino IDE..

Congratulations your are done ! stock up on your candy and wait for them trick-or treaters..

Happy Halloween !!

Intel® IoT Invitational

Runner Up in the
Intel® IoT Invitational

Halloween Decor Contest 2015

Participated in the
Halloween Decor Contest 2015