Rather than start yet another Ironman build thread with barely any content and nothing “new” (so far only helmet has been filled and sanded, and the chest, back and neck have been glassed) I thought I would focus on some of the areas that people seem to gloss over: the electronics. Specifically, this means lights and sounds, the goal of this thread being to hook up sound to various parts of a suit. While this is Ironman specific, the idea can be easily applied to any armor or weapon that needs to produce a high quality sound.
This project is based off of an Arduino Duemilanove. More info on Arduinos can be found at http://arduino.cc/. A quote from that site describing what an Arduino is:
“Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software.”
The Arduino is programmed using a simple to understand language based off of C++. In this situation, an Arduino might be a bit of an overkill, but a hobbyist like myself has a one sitting around anyhow. In addition to the Arduino, I used a Wave Shield project from Adafruit Industries (http://www.ladyada.net/make/waveshield/). This board connects directly to the Arduino, and reads WAV files off of an SD card.
Triggers for the sounds are based off of changing the input value on one of the pins. For this example, I use pull down resistors on the pins, with a switch that causes a connection to Vcc. For hooking up repulsors, a simple normally open momentary switch is used to change the value. During normal operation, the input is pulled to LOW by the resistor to ground, then the switch is closed it goes HIGH and plays the sound of a repulsor firing. When the switch is released, the pin returns to LOW and that state change causes the "repulsor charging" sound (kind of like a charging camera flash) to play. The helmet works similarly, the switch is pressed when the faceplate closes playing the characteristic "thunk." When the faceplate opens, the PIN value returns to LOW which causes it to play an opening sound (which right now is nothing). This could be extended to have a small switch play anything you wanted, even theme music.
I mentioned that I used pul-down resistors, here is how that is set up. Note however, that I will probably be changing the design to work backwards with pull-up resistors instead (pull down resistors on TTL circuits use more current than pull-up resistors).
For the code side of things, here is what I wrote. This was written in only a few minutes and is probably rife with bugs.
The Arduino with a waveshield:
Hooked up to a DIP switch for testing.
I need to etch the circuit board for the repulsors tomorrow (can't do it tonight since we're brewing beer ), and then hook the whole thing up, at which point I will post a complete video.
Let me know if you have any suggestions, or questions.
This project is based off of an Arduino Duemilanove. More info on Arduinos can be found at http://arduino.cc/. A quote from that site describing what an Arduino is:
“Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software.”
The Arduino is programmed using a simple to understand language based off of C++. In this situation, an Arduino might be a bit of an overkill, but a hobbyist like myself has a one sitting around anyhow. In addition to the Arduino, I used a Wave Shield project from Adafruit Industries (http://www.ladyada.net/make/waveshield/). This board connects directly to the Arduino, and reads WAV files off of an SD card.
Triggers for the sounds are based off of changing the input value on one of the pins. For this example, I use pull down resistors on the pins, with a switch that causes a connection to Vcc. For hooking up repulsors, a simple normally open momentary switch is used to change the value. During normal operation, the input is pulled to LOW by the resistor to ground, then the switch is closed it goes HIGH and plays the sound of a repulsor firing. When the switch is released, the pin returns to LOW and that state change causes the "repulsor charging" sound (kind of like a charging camera flash) to play. The helmet works similarly, the switch is pressed when the faceplate closes playing the characteristic "thunk." When the faceplate opens, the PIN value returns to LOW which causes it to play an opening sound (which right now is nothing). This could be extended to have a small switch play anything you wanted, even theme music.
I mentioned that I used pul-down resistors, here is how that is set up. Note however, that I will probably be changing the design to work backwards with pull-up resistors instead (pull down resistors on TTL circuits use more current than pull-up resistors).
For the code side of things, here is what I wrote. This was written in only a few minutes and is probably rife with bugs.
Code:
#include <FatReader.h>
#include <SdReader.h>
#include <avr/pgmspace.h>
#include "WaveUtil.h"
#include "WaveHC.h"
SdReader card;
FatVolume vol;
FatReader root;
FatReader file;
WaveHC wave;
// Setup input pins
#define REPULSOR 8
#define HELMET 9
int lastRepulsorState = LOW;
int lastHelmetState = LOW;
void setup()
{
// Setup inputs and outputs
pinMode(REPULSOR, INPUT);
pinMode(HELMET, INPUT);
Serial.begin(9600);
// Initiallize the SD card
card.init();
// Optimized reading
// Not sure if this makes a difference or not.
card.partialBlockRead(true);
// Open the FAT16 volume
vol.init(card);
// Open the root directory in the volume
root.openRoot(vol);
}
void loop()
{
// Get the current state of the pins
int repulsorState = digitalRead(REPULSOR);
int helmetState = digitalRead(HELMET);
// Amount of time to delay to simulate debouncing a switch
int debounce = 500;
// Check for signals to play a sound effect.
// Sound effects play on state changes on the input pins
// WAV files play asynchronously, so a new one will start before the first can be finished.
// For the helmet, low means the helmet is open, high means it is closed.
// The switch will be normally open with a pull down resistor on the pin.
// This value is tied to the eye lights (on/closed = HIGH)
if(helmetState == HIGH && lastHelmetState == LOW)
{
// Helmet just closed
char *name1 = "helmcls.wav";
playByName(name1);
delay(debounce);
}
else if(helmetState == LOW && lastHelmetState == HIGH)
{
// Helmet is opening
char *name2 = "helmopn.wav";
playByName(name2);
delay(debounce);
}
// Repulsor sounds, fire when the button is pressed, charge when it is released.
// Button is normally open and there will be a pull down resistor on the pin.
if(repulsorState == HIGH && lastRepulsorState == LOW)
{
// play the repulsor fire sound
char *name3 = "repsht.wav";
playByName(name3);
delay(debounce);
}
else if(repulsorState == LOW && lastRepulsorState == HIGH)
{
// play the repulsor charge sound
char *name4 = "repchg.wav";
playByName(name4);
delay(debounce);
}
// Store the states from the last iteration
lastHelmetState = helmetState;
lastRepulsorState = repulsorState;
}
void playByName(char *name)
{
PgmPrint("Playing: ");
SerialPrint_P(name);
// open file by name
if (!file.open(root, name))
{
PgmPrint("Error opening file.");
}
// create wave and start play
wave.create(file);
wave.play();
}
The Arduino with a waveshield:
Hooked up to a DIP switch for testing.
I need to etch the circuit board for the repulsors tomorrow (can't do it tonight since we're brewing beer ), and then hook the whole thing up, at which point I will post a complete video.
Let me know if you have any suggestions, or questions.