Pages

Friday, October 18, 2013

The Pumpkin Project: Part Two

Today we have the build pictures and code. There will be a final post covering the final set up on Halloween so keep an eye out for that. It will include video of the final setup.

The Hardware:
1 - PIR sensor -  http://www.adafruit.com/products/189
1 - 15ft phone wire -from Wal-mart
6 - LED flicker candles - from Target
5 - red flicker LEDs -
http://shop.evilmadscientist.com/productsmenu/partsmenu/576
10 - 220Ω resistors - from that compartment in my tool box
6 - Some random proto boards - https://www.sparkfun.com/products/8885 and https://www.sparkfun.com/products/8847
1 - Arduino Uno
1 - Raspberry Pi
1 - Powered Speakers - had some laying around
1 - Wireless card - had 3 laying around

The Build:
The first step was taking apart some cheap flicker led candles and clearing out space inside. After the led is removed the post holding the led can be removed from inside and the plastic guide for the power switch can be removed too. You will also want to remove the contacts from the battery housing and look free CR2032s. The last prep step is to drill a hole for the second led and the wire.




















The PIR sensor is just a standard pir from adafruit. I connected the jst cables to some phone line and run that back to the arduino. To get it mounted I cut a pass through for the connector where I wanted the sensor and used toothpicks through the mounting holes to hold it in place.

Now for the assembly. Each candle will need one yellow and one red flicker led and some 220Ω resistors. The diagram will look something like what is seen in the diagram. You have a resistor to vcc a resistor to ground the diodes connected in series and the pin connection for the arduino between the LEDs. The way this circuit works is when the pin is high no voltage can pass through the yellow diode since the diode is being reverse biased. When the pin goes low the red diode will be reverse biased.


For this project I decided to use phone line since it would keep my wires nicely bound and give me the 3 leads I needed. To keep things clean I just cut back the fourth wire. For the arduino side I built a harness for the lights. The main board has a ground and 5v bus and connector pins for providing ground and 5v to the harness as well as a pin for the PIR sensor input.




The Code:
On the arduino side we have code that will pass a value over serial when the pir sensor is triggered. The value is random and will tell the pi what dialog chain to run through. It will also wait for a clear signal from the pi before starting a new chain. During a chain the uno will parse a 5 character string to determine which pumpkins should be talking. The code can be seen below and on github at: https://github.com/igetio/PumpkinsV1/blob/master/arduino/PumpkinV1/PumpkinV1.ino


For the pi the code will play a dialog chain based on what the arduino says. When it strarts a chain it will tell the uno what pumpkin to light and will play an audio file. When the audio is done it will tell the uno to light the next pumpkin in the chain. When the chain is complete it will then wait 20 seconds before sending an all clear to the arduino starting the process over. The code can be seen below and is on github at: https://github.com/igetio/PumpkinsV1/blob/master/python/talkingPumpkinsV1.py


I have also included the audio files for the project on the github repository. If you have questions about the audio files they are pitch tempo and level shifted to some degree or another. https://github.com/igetio/PumpkinsV1

Thursday, October 10, 2013

The Pumpkin Project: Part One

So, it has been some time since I posted. I have a big update coming. I have finally started work on my talking pumpkin project. Soon I am expect to receive the last few pieces and that will let me start the final build.

Overview:
The pumpkin project is something I dreamed up this time last year having seen the thousand's of other pumpkin projects I thought why not build my own. What I have is a PIR sensor (more on that choice later) an uno and a pi. When the PIR gets tripped the uno sends a signal to the pi and a playback of a script is started. When the playback is over the pi tells the uno to start watching the PIR again. Yep, that's right, it's another talkingnpumpkin project.

The How:
So I ended up using a pi for audio and for managing the playback of the conversations. One of the "exciting" pieces of this project was getting the pi and uno to talk via serial over USB. Getting them talking was simple enough. Realizing that python does not like serial readline to end in \r\n meant some work and time spent wondering why my if statements didn't work. On the other side of things was the uno which can output serial as ASCII but only reads in one char at a time and compares it natively as hex code. After getting the two devices actually talking and handing control to each other things went much faster.

On to the sensor, the reason I used a PIR sensor, aside from them being cheap and me having one on hand, was the space where I am setting up this year is inside a screened in porch and people will be coming up a bent staircase to get to the door. When testing the PIR and an ultrasonic sensor the ultrasonic sensor was not getting good readings through the screen and its field of vision was too narrow.

The Build Plan:
It always comes down to time and money. I was hoping to do some work with wireless but have not had the money to get that up and running. My original plan was for 3 pumpkins but we actually ended up with 5. The plan for this year is to use phone line to wire up each pumpkin. In the interest of keeping the build simple this year I went with 2 different color flicker LEDs one for idle (yellow) and one for speaking (red). In a coming post the build instructions and code. Note: that this time I choose not to have the LEDs flicker in sync with the sound this is to minimize the number of pins used for this solution, knowing that my long term plan is to use a mesh network at which point I can switch to a more advanced logic.

What's Next:
Next steps are to build this thing and get the scripts (audio) recorded. After that I will put up more detailed instructions on what I did and some video of it running. For now I have some pictures of the pumpkins.








Monday, July 1, 2013

I Got a Whole Lot of Pi Here

So to break from the normal post here I am just going to say there has been a brief break in my building as I am playing with 2 new raspberry pi's. I am really only playing with the one right now getting it set up as an XBMC box which is why I had to go get a second one. So I have been setting it up to supplement what I already have at home. I am using it for streaming and media sharing. I have been through a few flavors and am currently running xbian on the the media center box. I also have not had a chance to unpack all my stuff and really get working on any new projects yet. I am not sure what I am going to do with my second pi yet but I am thinking it can help with a few projects this fall. for the media center pc I bought a few parts from newegg and have been running that on my TV. I picked up a USB hub and a 1TB external HDD. I should be getting back into building in the next few months but for the summer I am expecting my project volume to be a bit low. I will try to get some of my other older projects posted soon.

Tuesday, June 4, 2013

Failure: it Really is an Option

Taking a few moments to discuss the less desirable topic of failure I thought I would cover some lessons learned and horrible messes salvaged in unexpected ways. The lessons learned in protoboard wiring, seeing as I had always been more of a breadboard and existing PCB sort of guy. I learned that in some cases small wire (think cat5e strands) works well but if the pads are large or there is stress on the wire either you will melt the casing or break the wire. The other thing I learned is don't wire it up without a plan or spare parts. After making my first few protoboards without issue I tried wiring up an atmega on a protoboard, that did not end well. The first board I made didn't work either I wired the pins for an attiny backwards and was not able to get the wires and socket out. The failed attiny was salvaged with the help of my wife (Arina's Alchemy) and became a light up robot necklace.

I know I only have a few things to list here but I am just starting out after taking a break from electronics for 8+ years. The only tool I still had was my multimeter. Below are a few shots of the mistakes I have made. Note the robot was supposed to be the flicker flame circuit as shown in an earlier post. On the atmega you can't really see it but the whole thing is tied to ground and I missed pins and Vcc is tied to one of the ground pins on the socket. Let that be a lesson don't make when you are tired and have no plan.








Tuesday, May 28, 2013

Arduino Dice Box: Round One

Description:
I have not had much time to play recently. I was meaning to post this for some time now. I present the first iteration of my Arduino Dice Box. This project is a 5 way nav switch and a LCD display with I2C backpack that lets you roll virtual dice of various sizes and quantities. The program uses the random number function tied to an open pin to generate all the rolls. I have still not decided on a housing for this project and I am thinking of making another version that can use an 8x8 LED grid instead of a LCD display. So, lets get to it.

The Parts:
1 x Arduino Uno
1 x 5 Position switch (http://www.parallax.com/Store/Sensors/PressureFlexRPM/tabid/177/CategoryID/52/List/0/SortField/0/Level/a/ProductID/615/Default.aspx)
1 x LCD 16x2 display (http://www.adafruit.com/products/181)
1 x i2c / SPI character LCD backpack (http://www.adafruit.com/products/292)

The Buildout:
The switch is wired up to pins 2-6. The switch is wired with built in pull ups so you will want to wire that up with Vcc and GND. The other pins are:
  • Left is pin 2
  • Down is pin 3
  • Press is pin 4
  • Right is pin 6
  • Up is pin 5

The display is wired using i2c so aside from Vcc and GND you have 2 pins:
  • DAT (SDA) is A4
  • CLK (SCL) is A5 
The Code:

Code also available on GitHub here

The Output:
The output is the dice on the top and the roll on the bottom. if you change the die size or quantity it will display the last roll and die choice on the bottom. You can see from the attached pictures what the output looks like.



Tuesday, May 21, 2013

ATTiny Lantern - Battery Powered

As a small project around the time I made my ATTiny AVR I decided to make a battery powered flicker light and a pulsing night light. The lantern is a simple ATTiny running a modification of the ever available REAL flicker effect code that uses 3 LEDs. In this build I used 3mm LEDs 1 orange and 2 yellow. Parts for the lantern as as follows:

The Parts:
1 x ATTiny
1 x 8 pin DIP Socket
1 x Proto Board
1 x AA battery holder
1 x switch
1x Lantern
assorted lengths of wire I keep in a drawer

The Buildout:
Below is the diagram for the circuit note that the diagram below uses a coin type battery instead of a 2 x AA connector.



The Code:

also available on git-hub here


The Results:
The results here were a smallish circuit that I can place in a lantern and have it give off a flicker effect. Why not use on of those flicker LEDs you ask? I wanted to build something with a more random flicker and that I could adjust the flicker speed on.

Friday, March 22, 2013

ATTiny AVR ISP shield for Arduino Uno

So for several of my new projects I have decided to go with an attiny instead of an uno or atmega. This makes my project footprints smaller and reduces part counts. After getting my first two tinys programmed on a mini breadboard I wanted a more permanent tool to program them. I picked up a proto shield and built out this little bugger.

I have since programmed and fused six more tinys. When looking into setting up the attiny I found a few resources and the one I ended up using gave me and extra pwm pin over the standard setup for an attiny. The site I used was: http://www.ernstc.dk/arduino/attiny85.html
The wiring is simple as shown in the diagram (taken form the site linked above) or from the picture of the finished board.

The long term plan is to add a socket and wiring to the big open space in the middle to allow programming of an atmega so I will end up with a dual purpose AVR ISP shield. The only problem with getting the socket is there are way more useful things I can get with the money like a fleet of attinys or hundreds of 6 mm tactile switches :-), a few dozen 0 Ohm resistors, or more useful the 8x8 LED matrix with backpack. I guess it also does not help that I do not have any projects currently that need an atmega right now and I have a spare already flashed and ready to go. once I get the tinys fused I have been using the code from SparkFun for the LilyTiny which can be found here.

Parts List:
Misc -Wire (ripped apart cat5e)
1- 8-pin dip socket
1- Arduino Proto Shield (the official one worked well for this with the DIP traces on the side.

Some other useful resources for this project were:
http://arduino.cc/en/Tutorial/ArduinoISP
http://www.instructables.com/id/Program-an-ATtiny-with-Arduino/#intro
http://hlt.media.mit.edu/?p=1695