Jump to content

E-11 Arduino Project


Recommended Posts

While I wait for my armor I have been building my DoopyDoo's full resin blaster. I wanted to add lights/sound to it and I am somewhat familiar with programming the arduino. After drawing a ton of ideas from Skyone's post (http://www.whitearmo...er-effects-wip/) I ordered all my parts and started to get to work. I used alot of the same parts he did.

 

---------------

 

I'm not planning on doing an ammo counter at this time. I may later on though I'm not sure. The biggest challenge on this so far has been the size of the barrel on the full resin kit. A pipe build would have been wayyy easier. I'm still early on in the prototyping phase and thought I would show my progress so far.

 

Sounds:

1. Blaster

2. Stun

3. Jango Pistol

4. Boba Fett Flamethrower

5. ATST

6. Tie Fighter

 

Thanks again to Skyone for his help on this so far.

 

 

Here is my code so far:

I used the library provided by this post (http://arduino.cc/fo...?topic=117009.0)

//MAKE SURE TO USE PULL DOWN RESISTORS FOR SWITCH AND SELECTOR BUTTON
//LED'S NEED AT LEAST 9V
//PIN MAP:
//RED LED = pin 9
//BLUE LED = pin 10
//GREEN LED = pin 11
//SELECTOR BTN = pin 6
//TRIGGER = pin 7
//RESET = PIN 2
//CLOCK = PIN 3
//DATA = PIN 4
//BUSY = PIN 5
#include <Wtv020sd16p.h>
int resetPin = 2; // The pin number of the reset pin.
int clockPin = 3; // The pin number of the clock pin.
int dataPin = 4; // The pin number of the data pin.
int busyPin = 5; // The pin number of the busy pin.
const int buttonPin = 6; // the pin that the SELECTOR pushbutton is attached to
const int RedLedPin = 9;	 // the pin that the RED LED is attached to
const int BlueLedPin = 10;	 // the pin that the BLUE LED is attached to
const int GreenLedPin = 11;	 // the pin that the GREEN LED is attached to
const int triggerPin = 7; // the pin that the TRIGGER is attached to
// Variables will change:
int buttonPushCounter = 1; // counter for the number of SELECTOR button presses
int buttonState = 0;		 // current state of the SELECTOR button
int lastButtonState = 0;	 // previous state of the button
int triggerState = 0;		 // current state of the Trigger
int lastTriggerState = 0;	 // previous state of the Triger
long time = 0;		 // the last time the output pin was toggled
long debounce = 200; // the debounce time, increase if the output flickers

Wtv020sd16p wtv020sd16p(resetPin,clockPin,dataPin,busyPin);

void setup() {
//Initializes the module.
wtv020sd16p.reset();
// initialize the SELECTOR and Trigger button pins as a inputs:
pinMode(buttonPin, INPUT);
pinMode(triggerPin, INPUT);
// initialize the Barrel LED's as an outputs:
pinMode(RedLedPin, OUTPUT);
pinMode(BlueLedPin, OUTPUT);
pinMode(GreenLedPin, OUTPUT);
Serial.begin(9600); //Start serial interface (for debugging)

wtv020sd16p.asyncPlayVoice(9);

}
void loop() {
// read the pushbutton input pin:
buttonState = digitalRead(buttonPin);
triggerState = digitalRead(triggerPin);
// compare the buttonState to its previous state
if (buttonState != lastButtonState && millis() - time > debounce) {
// if the state has changed, increment the counter
if (buttonState == HIGH) {
 // if the current state is HIGH then the button
 // went from off to on:
 time = millis();
 Serial.println("Selector Button Pushed");
 wtv020sd16p.asyncPlayVoice(8);
 if (buttonPushCounter < 6)
 {
 buttonPushCounter++;
 Serial.print("Selector Button State: ");
 Serial.println(buttonPushCounter);
 }
 else buttonPushCounter = 1;
}
else {
}
}
// compare the triggerState to its previous state
if (triggerState != lastTriggerState) {
// if the state has changed, do something
if (triggerState == HIGH) {
 Serial.println("Trigger Pushed");
 Serial.print("Selector Button State: ");
 Serial.println(buttonPushCounter);
 SelectorPosition();
}
else {
}
}
// save the current state as the last state,
//for next time through the loop
lastButtonState = buttonState;
lastTriggerState = triggerState;
}

void SelectorPosition(){
switch (buttonPushCounter) {
case 1:
//BLASTER - RED
 digitalWrite(RedLedPin, HIGH); //Turns on Red LED
 Serial.println("BLASTER FIRE SOUND IS PLAYED");
 wtv020sd16p.asyncPlayVoice(0);
 delay(780);
 wtv020sd16p.stopVoice();
 digitalWrite(RedLedPin, LOW); //Turns off Red LED
 break;

case 2:
//STUN - BLUE
 digitalWrite(BlueLedPin, HIGH); //Turns on Blue LED
 Serial.println("BLASTER STUN SOUND IS PLAYED");
 wtv020sd16p.asyncPlayVoice(1);
 delay(1000);
 wtv020sd16p.stopVoice();
 digitalWrite(BlueLedPin, LOW); //Turns off Blue LED
 break;

case 3:
//JANGO - PURPLE
 analogWrite(RedLedPin,153);
 analogWrite(BlueLedPin,102);
 analogWrite(GreenLedPin,0);
 wtv020sd16p.asyncPlayVoice(2);
 delay(1000);
 // wtv020sd16p.stopVoice();
 analogWrite(RedLedPin,0);
 analogWrite(BlueLedPin,0);
 analogWrite(GreenLedPin,0);
 break;

case 4:
//FLAME - ORANGE
 analogWrite(RedLedPin,255);
 analogWrite(BlueLedPin,0);
 analogWrite(GreenLedPin,102);
 Serial.println("Fourth Buttton Push");
 wtv020sd16p.asyncPlayVoice(3);
 delay(3200);
 analogWrite(RedLedPin,0);
 analogWrite(BlueLedPin,0);
 analogWrite(GreenLedPin,0);
 wtv020sd16p.stopVoice();
 break;

case 5:
//AT-AT - RED
 Serial.println("Fifth Buttton Push");
 digitalWrite(RedLedPin, HIGH); //Turns on Blue LED
 wtv020sd16p.asyncPlayVoice(4);
 delay(780);
 wtv020sd16p.stopVoice();
 digitalWrite(RedLedPin, LOW); //Turns off Blue LED
 break;

case 6:
//TIE FIGHTER - GREEN
 digitalWrite(GreenLedPin, HIGH); //Turns on Green LED
 Serial.println("Sixth Buttton Push");
 wtv020sd16p.asyncPlayVoice(5);
 delay(900);
 wtv020sd16p.stopVoice();
 digitalWrite(GreenLedPin, LOW); //Turns off Green LED
 break;
}
}
 
Edited by gmrhodes13
link removed no longer working
Link to comment
Share on other sites

When I was test fitting all my components I had to hollow out some of the inside of the barrel for the speaker to fit. I plan on gluing it to the end cap. It's going to be tough once all the wires are in there.

Link to comment
Share on other sites

  • 2 months later...

I am so happy to see skyones code and documentation be put to use, modified and shared again by others. This is what open source is all about. Together we improve as a whole. :)

Link to comment
Share on other sites

Peter,

 

I updated the link in the first post for the amp. The only resistors I used were 10k ohm "pull down" resistors for the trigger and selector switch. I'm glad to read that you fixed your blaster. Isn't this place great!

Edited by kupertrooper
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...