So I’ve been coming here for a while now and I’ve seen enough posts and questions about sound effect boards that I know there aren’t a lot of options out there. Well I just got an Arduino and WaveShield last week (care of http://adafruit.com/), and this was my first project (literally I’ve never soldered anything before last Monday!).
This setup if for a Portal Gun (Yes, that’s Portal… not Proton) - but it can be easily adapted to work for your gun, your pack, etc… I’m going to adapt it for my pack soon enough (and when I do I’ll post the sketch code that goes with it), but I thought I’d post this now, cause who knows when I’ll get back to it.
I suspect you may find things a little more complicated than you anticipated. I’m not expert on the Arduino but I have been researching it for use in a PKE meter, and in the case of a portal gun, you only have a few LED’s you need to control, but in the case of a proton pack or PKE, you have more like 30-40, and even if you ignore the gun you’ve still got 19 to deal with which is way more ports than the Arduino has.
To control all those LED’s you’re probably gonna need a controller chip or two in addition to the Arduino and LED’s.
Yea, that’s a good point. I suspect I’ll run into a bunch of issues like that when I adapt this for the proton pack.
The portal gun actually has about 30 or so LEDs, but the functionality is really simple: 3 reds are always on, it’s either glowing blue… or it’s glowing orange, and sometimes the whites light up (when you fire the gun).
The Arduino only outputs 5v… which means that all of the blue/orange lights would have to be run in parallel (blue LEDs are 3.5Vf @30mA and orange are 4.5Vf @ 50mA) if they were powered off of the arduino and I’m pretty sure that’s going to be way too much drain on the board.
I’ve been looking into different ways to power the leds; so far my ideas are:
integrating a current amp
put the lights on a separate circuit and use DPDT switches to sync the lights with the sound
power the leds from the source 9V supply and switch on-off the current with transistors from the arduino
Again I’m pretty new to this, so any help or suggestions you have would awesome
I looked into these before. It is definitely possible here if we could drive the leds. i guess a custom shield could work.
Edit: even having to use two would work and be pretty cheap (one in the gun and one in the pack). You can have them talk to each other fairly easily. Now having to use more than one for just the pack may not work well. But one for the sound, one for the gun, and one for the pack would work out just fine as long as they can all talk to each other. Using two for the pack, with one having sound would work too and give more usable leds. i have forgotten how many leds each one of these can utilize though…
Well there are 14 digital i/o pins. So you can have a total of 14 input and output (14 total, not 14 of each…) so the pack would need 4+14+1. The 1 would be for the gun board to send info back. So, driving the bar graph will be a challenge. The cyclotron lights will not be hard. the bar graph would need either two of them, which would be a pain. Maybe an addon would allow that type of thing to happen. The sound could be driven from the gun board if need be, it would not be insane amounts of code. I really have no idea what can be done without more research, but it seems possibly.
I should also note that it has 6 analog inputs as well. Those could be used, but the pack would need two boards… or you could run really long wires to the gun and run the cyclotron lights from there and do the sound from the pack. tons of things here, once again, more research is needed.
I made my trap front display with an Arduino and a 10xLED bargraph. It’s incredibly easy to work with, especially compared to my PIC-powered pack lights.
I think you can have up to 19 digital outputs (using the analog inputs as digital outputs, plus the regular ones) or you can use multiplexing to control many many more LEDs.
Well the first question is do you think that this can be done? I see no reasons why it is not possible to get an accurate pack and gun kit out of this. The hardest will be the bar on the pack and gun. I do not have one of these in front of me right now, so I cannot test things out. I downloaded the development software and am reading about it, but without one to test on I am kinda dead in the water. Too bad there is not an emulator to test the code on…
managing the lights with a separate arduino and custom shield is a great idea.
one thing to keep in mind for anyone planning to try out the WaveShield is that only “pins 6, 7, 8, 9 and the 6 analog in pins (also known as digital i/o pins 14-20) are available”
well lets see here. the gun has 5 switches, so lets consider the arduino as only having pins 6, 7, 8, 9 and one analog as being usable. I would like to see this done with one arduino and a few extra shields. Sound looks to be pretty taxing on the thing, so that may not be possible though. But having 5 digital i/o pins (since the last analog would be a digital i/o if i am reading correctly) should work for us. we could attach the cyclotron lights to one pin, and each bar to a separate pin as well and just drive those. That would leave two more for the rest of the gun lights including something to do with firing. On second thought maybe two of them would be needed. At the price for these though, that would be fine really. Damn I wish i could test this right now.
I am about to buy one if someone can confirm that this is possible to do (not looking for a definite, just a possible). The custom shield would not be hard, just get the right ic and let that do the brunt of the work as most people seem to be doing. Wish i had one of these to toy with right now to test before i buy or something.
I’m thinking it would be best to have one chip for the power cell and cyclotron, and other one for all the gun functions.
I bought the starter set from adafruit.com, it comes with lots of goodies.
Here’s one of my trap sketches, it just makes the bar graph light up all the way, then down again, then half way, then back down, then repeat. Pretty straightforward if you’ve done any C, Java, etc.
//Trap lighting
//10 yellow LED bar graph
//yellow on pins 0-9 (220ohm), blinking red on 10
//by R2DEVO @gbfans.com
void setup() // run once, when the sketch starts
{
for(int i=0;i<=10;i++)
pinMode(i, OUTPUT); // sets the digital pin as output
//startup sequence
for (int f=0;f<10;f++)
{
digitalWrite(f, HIGH);
delay(200);
digitalWrite(f, LOW);
}
for (int f=9;f>=0;f--)
{
digitalWrite(f, HIGH);
delay(200);
digitalWrite(f, LOW);
}
digitalWrite(10, HIGH); // sets the LED on
}
void loop() // run over and over again
{
//all the way up
for( int k=0;k<10;k++)
{
digitalWrite(k, HIGH); // sets the LED on
delay(100);
}
//all the way down
for(int j=9;j>=0;j--)
{
digitalWrite(j, LOW); // sets the LED off
delay(100);
}
//half way up
for( int k=0;k<5;k++)
{
digitalWrite(k, HIGH); // sets the LED on
delay(100);
}
//half way down
for(int j=9;j>=0;j--)
{
digitalWrite(j, LOW); // sets the LED off
delay(100);
}
}
I really wish that they had them in stock… I found some on ebay. Adafruit wont have them till the 20th, I dont want to wait that damn long.
Edit
Ordered from hacktronics. Got a starter kit from there. Doesnt have as many of the parts as adafruit, but has some that they didnt. I am happy with what I got from there and the price I got it for.
I have a way to drive basically an unlimited number of leds from just 3 pins on this bad boy (limited only by power constraints). ordered the parts for that today. once it comes in I will make it so. As it is looking, will only need one arduino to do this. you will then need a wave shield and then a custom shield. Only real testing will tell, but it looks easy enough to use just 1 of these. Only issue that we may have is running out of analog inputs.
I will post any updates that are made on my end here.
Just wanted to mention that I picked up a fist full of npn 2n2222 switching transistors last night and now I can power the LEDs directly off of the source 9v (that feeds into the arduino), control switching them on and off with the arduin0 analog outs.
So now I’m using digital pins 6, 7, and 8 as inputs and analog pins 0-5 (digital 14-19) as outputs to the base of the transistors, controlling power to the lights.
pm me, i got some interesting developments that should work out just fine. waiting for my stuff to get here to try this out, but should be simple to do and extremely cheap to build. would need a few ics that are $3 each though, each one drives 8 leds, so i guess5 of them just to be safe…
Hey guys, just wanted to let all of you know that my arduino came in. I have it here with a 4 led powercell effect going on that the speed can be changed on via a potentiometer. I may make a recording later if i can find my cvs cam. As I have said before, I have a way to drive as many leds that I want from just 3 pins. Not too shabby. Those parts are not in yet so I cannot mess with that feature. Once I have the breadboard done for the entire light system, I will start to design a custom shield that will plug into the arduino. I am aiming for this to be 100% plug and play here. Unfortunately I need to get more leds to do anything else useful. Over half of the radio shack ones were defective… wont be buying any from there when I am in a pinch.
-Frank
edit: Made a little demo, 5 minutes long. Informative and all that shit. Uploading now.
Well everytime i upload the damn demo it wont work. oh well. I have it on my computer. Anyways. I got the chips in a few days ago. Today was the first time that I had to sit down and mess with the thing lately. The good news is that it works. The bad news is that I need to order more chips now (wasnt gonna get 6 of them if they didnt work for what i needed). I have some code that will light up each light (16 of them) in succession with a half second pause between them. It then goes backwards. The sound board should be in tomorrow. Once that is in then I can really start work on this. I do not want to code it all only to have to go back and redo it once I get my sound module. I will need to put the module together so it may take some time, but I have not forgotten about this. I have been emailing mark at hacktronics almost every day getting help with various things. Hopefully I have something to show shortly (even an incomplete powercell cycling, with the cyclotron, and some sounds).