Props Airsoft Flash Grenade... (Need Electronics Help)

Status
Not open for further replies.

Halcyon25

Jr Member
To all you Electronic Guru's...

Here is a basic description of what I want it to do,
I want to push a button that starts a 5 sec delayed timer that lights up 4 led's, on the fifth sec I want a set of LED's to flash 3 times in one sec and then turn off.

My plan is to fit all the circuitry, batteries and leds, into a package the size of either one of these packages but not limited to these styles but will determine how many flash LED's will be needed...
XM84 flashbang
USB frag
Halo frag and Plasma

But first, the electronics...
Here are the LED's I am looking into for this,
Timer LED's - 5MM GREEN LED ROUND - Digikey P/N: 754-1561-ND
Flash LED's - SSC-Z7 LED

How would I accomplish this? In layman's terms please... I already have a basic 555 led strobe circuit nocked out I just don't know if theres anything I could add to it to make this work or if I have to redesign it to function the way I want it to...


Thank you for your help

Chris
 
So.. a few things!

First, this is a question for the "Help!!! For Electronics" thread over in the noob forum. Yes we're infantrymen, but we can still ask questions on those threads to reduce clutter (I ask questions all the time there!) This goes double for this post, because ThatDecade is an electronics god, and he answers a TON of questions on that thread, it makes it easier for him to find your question.

I'll answer my own answer here since this is posted up anyways!

There may be an easy way to use a capacitor and other stuff to make a fully automated strobe effect, but since it's a more complicated strobe pattern, I'd personally use a microcontroller to get the job done. If you pick a good power supply, you could cram a teensy (or any of the hundred similar microcontrollers) a battery and some LEDs in a golf ball, the form factor on modern microcontrollers is pretty ridiculous. I saw one the other day that was the size of a thumbnail, but it required a fairly high level of electronics knowledge to use since it had no power control or protection.

A prefab controller (a good one) will have most of the power regulation you need. I recently wired and ran a teensy based LED strobe system. These types of controllers trade in a lot of soldering expertise and require a bit more software programming knowledge, but I find that's a lot harder to mess up, and a lot less dangerous to the hardware.

If I were putting a strobe system in that XM84, I'd get the following:
teeny2: $15
LEDs: like 5c each from a good seller
resistors: like 1c each
power supply... My goto is 3 AA Batteries.

Then you can write it up in like ten lines of C which anyone with one semester of programming knowledge could easily do for you, myself included.

This is a bit different than your idea, and I don't know what your money situation is like, but I've grown to REALLY love the arduino platform, it pretty easily solves a lot of problems and there are some good competition systems that run for dirt cheap.

Edit:
The links for your LEDs, I can't seem to get them to work, I'm still in Japan so it may be that? A lot of websites don't seem to work here. The LEDs you use depends on the size of power you want to use, and how bright you actually want them to get.
 
So.. a few things!

First, this is a question for the "Help!!! For Electronics" thread over in the noob forum.

Oh shoot... I apologize, I looked right past that thread... it will also be the development thread once the circuitry is layed out...
If you can access Digikey.com over there, I updated the first post with the part numbers... I like the size of that teensy microcontroller but Im not sure if it would be safe to use it for this application, not that it couldn't do it, but if the power input for the Teensy is only 5v and the input for the flash CXA's are 9v each and I would be looking at using at least 6 of those. Would I need two different batteries to operate the system?

Edit: Did some more digging and found more info, I guess they can handle up to 12v input...
 
It is generally trivial to bring in external power to drive high powered LEDs. The microcontroller can easily handle the timer lights, the numbers look okay to me (But wait for professional input), but I have some 10mcd LEDs hooked up with no problem to my teeny3.

If you want to blind someone, you could always get one of these expensive bad boys:
http://www.superbrightleds.com/moreinfo/high-powered/30w-white-high-power-planar-cob-led/1255/

Haha, 30v would be pretty hard to power. The 9v might be nice because you can probably fairly easily fit 2 AA and 1 9v in a flashbang case.


But before you go buying high power LEDs and a microcontroller, it's probably best to wait for a response from ThatDecade. These specialty LEDs make me a bit more nervous about me giving you information that will break stuff.

I will tend to come off as a teensy advocate when I talk microcontrollers, but so far they've served me very well, the t3 has amazing performance (beefy ARM processor) for a tiny price (17$ for the 3), and the new wave of small microcontrollers to compete with the teensy haven't really hit the market fully yet, but some of the ones I've seen sacrifice too much to be a little bit smaller, things like usb connectors, power regulators, or too many pins lost. But that's the beauty of the forum, get lots of different ideas on a project, and then YOU get to decide which one you like! Maybe it won't be mine, that's fine by me! (I am sure there will be a better idea, but I am just tossing my idea out there also!)
 
My ears are ringing, lol.

The 555 and other logic chips are good for sequential animation, but it seems like you want a specific LED animation. A microcontroller is the best way to achieve this. A small arduino is the cheapest and easiest to learn.

I'm not sure on your experience level, you'll at least need to be able to solder. Here are some mini arduino compatible breadboard kits.
http://www.adafruit.com/products/1315
http://www.adafruit.com/products/1086
http://www.adafruit.com/products/91

May I ask why you are using surface mount LEDs? Those will be a pain to wire up. Better off with some 3mm or 5mm high power LEDs. I buy mine on ebay in bulk for cheap. Even your CX won't be very bright without a lens to focus the light.

If you really need to send more power to an LED than 5V at 50mA, then you can use a transistor switch to drive a bigger power hungry lamp.

9 volt battery huh. icky
If you really want to use a 9 volt cell, can wire up a voltage regulator to power the microcontroller at 5volts. Then use a transistor to deliver the full 9v to each LED. Will need a resister to protect the LEDs, say 500 ohms for the little LEDs and 50 ohms for the big LED.

I don't expect the big LED to last long at a current of 250mA. You can find a heatsink that the big LED to fit in to cool it down and increase it's lifespan.

edit:
See next post for the main LED selection.
 
Lol... ok, I'll start looking into the programs and other items needed for the mini arduino.


My ears are ringing, lol.

May I ask why you are using surface mount LEDs? Those will be a pain to wire up. Better off with some 3mm or 5mm high power LEDs. I buy mine on ebay in bulk for cheap. Even your CX won't be very bright without a lens to focus the light.

Im working on designing a custom pcb for this grenade, though I suppose your right, I'll give the easier option a try first but space is limited, so I may end up going back to them later...
These are intended for an abandoned factory we play at, I don't normally say this just because my night sight is pretty good but in most area's of the field when I say you can not see your fingers an inch from your face... I seriously mean it... most of us use flashlights that output 80-200 Lm (focused) and still feel blinded, so I think this grenade with a minimum of 8 CXA's outputting 425 Lm each (unfocused) will be enough. Though the fun part is figuring out how to make it all work...


If you really need to send more power to an LED than 5V at 50mA, then you can use a transistor switch to drive a bigger power hungry lamp.

Could you expand on this a little more, I really only know the basics of electronics and how they work...


9 volt battery huh. icky
If you really want to use a 9 volt cell, can wire up a voltage regulator to power the microcontroller at 5volts. Then use a transistor to deliver the full 9v to each LED. Will need a resister to protect the LEDs, say 500 ohms for the little LEDs and 50 ohms for the big LED.

I was planning on running one of these bad boy's to ensure I had enough voltage and amperage to run the whole system...
Turnigy nano-tech 260mah 2S 35~70C Lipo Pack

To much?


I don't expect the big LED to last long at a current of 250mA. You can find a heatsink that the big LED to fit in to cool it down and increase it's lifespan.

I don't expect the heat to be an issue mainly because the light will only be on for a second and only used once every few minutes...
 
So to save not only myself but those of you that are helping me from further headaches, I have found a better led that runs on a similar voltage to the arduino...
Behold, The SSC-Z7, 900 Lm's of pure unbridaled white light... lol... now the fun part is trying to find them for less then $8 bucks a pop...

Does anyone have a secret place they like to go for cheap stuff?
 
ok... So I got the Arduino micro today and started playing around with the coding... its slowly turning out harder then I was planning it on being but its all fun still... Anyways, I can get it to do most of what I want as separate strings but not all at once...

Would some one mind taking the time to either walk me through setting it up or write the code for me?

Edit: I suppose my biggest question is how do I add two switched to the code? one to turn on the chip, and one to activate the code.
 
When I do arduino switches, you want to just capture the LOW and HIGH on them through digital inputs. If you wire them correctly, you should be able to read them with code like:

(in setup()) pinMode(whateverdigitalpintheswitchison, INPUT);
(in loop() or whatever function) if(digitalRead(whateverdigitalpintheswitchison) == HIGH) dowhatever;

Whether you read HIGH or LOW depends on how you wire it, but it's trivial to just run the serial monitor and have it output the current state of the switch if you're not 100% sure.

However, the switch to turn on the system is a bit different from the switch to activate the flash. The "on" switch has to be wired to the battery directly, and doesn't have actual code. You need to get an on/off switch that will cut the connection between the battery and the arduino, to turn it on and off.

Here is some code! Feel free to fix it to be better, just threw it together as a rough example:
https://gist.github.com/katsudon/2cf447e65a0e3b38f589
 
When I do arduino switches, you want to just capture the LOW and HIGH on them through digital inputs. If you wire them correctly, you should be able to read them with code like:

(in setup()) pinMode(whateverdigitalpintheswitchison, INPUT);
(in loop() or whatever function) if(digitalRead(whateverdigitalpintheswitchison) == HIGH) dowhatever;

Whether you read HIGH or LOW depends on how you wire it, but it's trivial to just run the serial monitor and have it output the current state of the switch if you're not 100% sure.

Here is some code! Feel free to fix it to be better, just threw it together as a rough example:
https://gist.github.com/katsudon/2cf447e65a0e3b38f589

hmm... I've been digging around and found some coding that relates to pushbuttons but couldn't get it to function with what I have... I'll give your code a try but I can see its far more complex then what I have been toying with, I might need to ask you a few more questions later...

Here's what I have been using, feel free to modify it as well... be gentle, I know its not clean but aside from the pushbutton code, it does what I'm aiming for...

Code:
int led = 3;           // the pin that the LED is attached to
int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by

void setup() {
   // initialize the LED pin as an output:
   pinMode(3,OUTPUT);
   pinMode(4,OUTPUT);
   pinMode(5,OUTPUT);
   pinMode(6,OUTPUT);
   pinMode(7,OUTPUT);
   pinMode(led, OUTPUT);
   
   digitalWrite(3, HIGH);          //ON LED1
   delay(1000);                    //delay for 1000ms
   digitalWrite(4, HIGH);          //ON LED1
   delay(1000);                    //delay for 1000ms
   digitalWrite(5, HIGH);          //ON LED1
   delay(1000);                    //delay for 1000ms
   digitalWrite(6, HIGH);          //ON LED1
   delay(1000);                    //delay for 1000ms
   digitalWrite(7, HIGH);          //ON LED1
   delay(100);                     //delay for 100ms
   digitalWrite(7, LOW);           //OFF LED1
   delay(100);                     //delay for 100ms
   digitalWrite(7, HIGH);          //ON LED1
   delay(100);                     //delay for 100ms
   digitalWrite(7, LOW);           //OFF LED1
   delay(100);                     //delay for 100ms
   digitalWrite(7, HIGH);          //ON LED1
   delay(100);                     //delay for 100ms
   digitalWrite(7, LOW);           //OFF LED1
   delay(100);                     //delay for 100ms
   digitalWrite(3, LOW);           //OFF LED1
   delay(100);                     //delay for 100ms
   digitalWrite(4, LOW);           //OFF LED1
   delay(100);                     //delay for 100ms
   digitalWrite(5, LOW);           //OFF LED1
   delay(100);                     //delay for 100ms
   digitalWrite(6, LOW);           //OFF LED1
   delay(100);                     //delay for 100ms 
}

void loop()
{
   // set the brightness of pin 3:
   analogWrite(led, brightness);    

   // change the brightness for next time through the loop:
   brightness = brightness + fadeAmount;

   // reverse the direction of the fading at the ends of the fade: 
   if (brightness == 0 || brightness == 255) {
     fadeAmount = -fadeAmount ; 
   }     
   // wait for 30 milliseconds to see the dimming effect    
   delay(30);
}


However, the switch to turn on the system is a bit different from the switch to activate the flash. The "on" switch has to be wired to the battery directly, and doesn't have actual code. You need to get an on/off switch that will cut the connection between the battery and the arduino, to turn it on and off.

lol... Its funny, I totally had a brain fart last night when I asked that... Derp... I managed to find a schematic that showed me where to hook up the battery and got that part setup...

Thank you
 
I am always more than happy to help as much as I can, especially with coding. Don't worry about asking questions, even if they seem stupid.

For the code, there are two things.. The first is that it doesn't detect button presses. The moment the board is turned on, it looks like it starts the flashbang sequence. That's not bad, but it means you have to flip the power on and off to restart the flashbang. If you want a button for power, and a separate one for activating the bang, you need to move the code out of the setup.

The other thing is, you want to avoid using delays as much as possible. In this instance, there isn't much going on, so it's okay, but if you get into more advanced stuff, you'll want to take measures to avoid them so that you can prevent the system from hanging. Again, not an issue this time, just keep it in mind in the future.

I wrote some new code, it has the timer flutter you wanted, as well as PWM control for the flash. I added a flourish where how much it brightens each time increases incrementally, but you can remove that if you want. When you hook your system up, be sure to look at the data sheet, some microcontrollers will only allow analog PWM on SOME pins but not all. It's important to hook it up to the right ones.

here is the code
https://gist.github.com/katsudon/2cf447e65a0e3b38f589

Here is a picture of my wiring:
flashbangwire.jpg


And I made a video of it working!!!
 
Last edited by a moderator:
Thank you Katsu, I finally got it working on my end this afternoon and have been trying to get my Standby/Armed light to blink again. That was the code I had looped in my last post, this is to let me know the Arduino is on and primed...

How would I code this back into what you have provided?
Is there a way to increase the speed at which the flash led, flashes?
Also Debouncing? Considering Im going to be throwing this thing, should I consider it and how would I code this into the code you provided...

I would like to learn how to add and remove code the right way, so if you don't mind, can you walk me through the process?

I have also provided the modified version of your code so you can see what I did... (lol, all I did was remove the section of code that told the third led to blink)

Code:
//Code for flashing stuff. There are other ways to do this,
//but this is how I am writing it at 6am, feel free to change it!
//These are wherever the stuff is hooked up to, numbers mutable
int switchpin = 2;
 
int timerled[4];
int flashled = 7;
int mode = 0;
int flashcounter = 0;
int brightness = 0;
int fadeAmount = 5;
void setup(){
   //Set to the pins they're hooked to
   timerled[0] = 3;
   timerled[1] = 4;
   timerled[2] = 5;
   timerled[3] = 6;
   pinMode(switchpin,INPUT);
   for(int i = 0;i < 4;i++)
      pinMode(timerled[i],OUTPUT);
   pinMode(flashled,OUTPUT);
}
void loop(){
  //Start the timer when the button is pressed
   if(digitalRead(switchpin) == HIGH && mode == 0)
      mode = 1;
   //count up sequence
   if(mode == 1){
      //Incrementally turn on the timerLEDs
      for(int i = 0;i < 4; i++){
         digitalWrite(timerled[i],HIGH);
         delay(950);
      }
      mode = 2;
   }
   //flash sequence, this will flash three times
   else if(mode == 2 && flashcounter < 3){
      //brighten
      while(brightness <= 255){
         analogWrite(flashled,brightness);
         brightness += fadeAmount;
         fadeAmount = fadeAmount > 20 ? 20 : fadeAmount + 1;
         delay(10);
      }
      fadeAmount = 5;
      //darken
      while(brightness > 0){
         analogWrite(flashled,brightness);
         brightness -= fadeAmount;
         fadeAmount = fadeAmount > 20 ? 20 : fadeAmount + 1;
         delay(10);
      }
      fadeAmount = 5;
      flashcounter++;
   }
   //Reset everything once the flash is done
   else if(mode == 2 && flashcounter >= 3){
      flashcounter = 0;
      mode = 0;
      analogWrite(flashled,0);
      for(int i = 0;i < 4;i++)
         digitalWrite(timerled[i],LOW);
   }
}

Quick shot of what Im working with... Yes I know Im not using resistors, I don't have any that are the right type

0630131932_zps9f384694.jpg

 
Last edited by a moderator:
Video is cool, good job!

-------------------
Your code doesn't need debouncing. That is only for buttons that activate code directly. The example you posted correctly activates your sub-function indirectly by setting mode = 1.

Button bounce events are brief, but can affect the way your program runs. Because your code takes time to process, button bounce will gone by the time that mode=0 again and ready for the next button press.

-----------
Same as Katsu, Also want to point out delays are bad. What you have here is ok, leave it as is. A better method is to use millis() for timing related functions. Each loop can compare to see if it is time to perform the next animation. This frees up the main loop to do other things while wait for the next animation event.
http://arduino.cc/en/Tutorial/BlinkWithoutDelay

--------------
Let's see, editing example code.

1. Save a backup of the original,
2. Edit as much or little as you like
3. Hit Verify button in arduino program to see if it compiles, if not undo changes and try again
4. Flash to chip, see if it works, if not then try again
5. Repeat a few dozens times to tweak things exactly how you like

Really, is just experimentation. Learning what you can and can't change. There are tutorials out there, but is more fun just playing around. :p

Some good pages
http://arduino.cc/en/Tutorial/BareMinimum
http://arduino.cc/en/Tutorial/Blink
http://arduino.cc/en/Tutorial/Fade

or really, just this one, ha
http://arduino.cc/en/Tutorial/HomePage
 
Last edited by a moderator:
Video is cool, good job!

-------------------
Same as Katsu, Also want to point out delays are bad. What you have here is ok, leave it as is. A better method is to use millis() for timing related functions. Each loop can compare to see if it is time to perform the next animation. This frees up the main loop to do other things while wait for the next animation event.
http://arduino.cc/en/Tutorial/BlinkWithoutDelay

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

Thank You thatdecade, I was just about to post an "I give up" until I read that section again and took a closer look at the link, Ok I think I got it... I don't like how it starts flashing the led while the flash sequence is going, is there something missing to tell it to wait until that string completes?

I suppose I wouldn't need it considering the string would already be active after its been thrown, But I would like it to not go off while its being transported or prepped... The reason for this is because while I have it plugged into the computer it will activate the code without pressing the button, to the point where I can quite literally breath on it and it goes of sort of thing, but it stops when I disconnect and run it off of battery, and while on either power supply if I drop it a 1/4 inch or tap it, it will activate as well?!?! Do you guys have/had this problem as well?

How does that look?

Code:
// constants won't change. Used here to 
// set pin numbers:
const int ledPin =  3;      // the number of the LED pin

// Variables will change:
int ledState = LOW;             // ledState used to set the LED
long previousMillis = 0;        // will store last time LED was updated

// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long interval = 500;           // interval at which to blink (milliseconds)

int switchpin = 2;
int timerled[4];
int flashled = 7;
int mode = 0;
int flashcounter = 0;
int brightness = 0;
int fadeAmount = 5;
void setup(){
   //Set to the pins they're hooked to
   timerled[0] = 3;
   timerled[1] = 4;
   timerled[2] = 5;
   timerled[3] = 6;
   pinMode(switchpin,INPUT);
   for(int i = 0;i < 4;i++)
      pinMode(timerled[i],OUTPUT);
   pinMode(flashled,OUTPUT);
}
void loop(){
  // blink the LED.
  unsigned long currentMillis = millis();
 
  if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED 
    previousMillis = currentMillis;   

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
      ledState = HIGH;
    else
      ledState = LOW;

    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);
  }
  //Start the timer when the button is pressed
   if(digitalRead(switchpin) == HIGH && mode == 0)
   mode = 1;
   //count up sequence
   if(mode == 1){
      //Incrementally turn on the timerLEDs
      for(int i = 0;i < 4; i++){
         digitalWrite(timerled[i],HIGH);
         delay(950);
      }
      mode = 2;
   }
   //flash sequence, this will flash three times
   else if(mode == 2 && flashcounter < 3){
      //brighten
      while(brightness <= 255){
         analogWrite(flashled,brightness);
         brightness += fadeAmount;
         fadeAmount = fadeAmount > 20 ? 20 : fadeAmount + 1;
         delay(10);
      }
      fadeAmount = 5;
      //darken
      while(brightness > 0){
         analogWrite(flashled,brightness);
         brightness -= fadeAmount;
         fadeAmount = fadeAmount > 20 ? 20 : fadeAmount + 1;
         delay(5);
      }
      fadeAmount = 5;
      flashcounter++;
   }
   //Reset everything once the flash is done
   else if(mode == 2 && flashcounter >= 3){
      flashcounter = 0;
      mode = 0;
      analogWrite(flashled,0);
      for(int i = 0;i < 4;i++)
         digitalWrite(timerled[i],LOW);
   }
}

I have also started considering canister designs and am really digging this one...
syndicate_concept___emp_grenade_by_torvenius-d5e316o.jpg


As well as started to build the first shell prototype... just need to replace the pushbutton with a momentary... and the paint can on the right is what it was, just cut off the bottom and replaced it with the cap... I saw a nice looking grenade prop on youtube the other night made out of PVC, so I might give that a try for the MkII before I consider pushing for a 3D printed one...
0701131813_zps1732a5b7.jpg



Thank you

Chris
 
Last edited by a moderator:
Nice canisters.

The breathing to activate the push button is caused by static. Turn on the pull-up to eliminate the problem.

digitalWrite(pin, HIGH); // turn on pullup resistors

http://www.arduino.cc/en/Tutorial/DigitalPins

This also means however, that input pins with nothing connected to them, or with wires connected to them that are not connected to other circuits, will report seemingly random changes in pin state, picking up electrical noise from the environment, or capacitively coupling the state of a nearby pin.
 
I would like to add, I recently had a problem where I could activate buttons by tapping the (covered)wires running from them. It turned out to be a grounding problem, and when I rewired it, it was fine. It may be prudent to check your wiring
 
Hmm... Turns out I have an electric personality........ da dum, tssh... Sorry, had to go there, lol.

Thanks thatdecade, that took care of my magic ability while its unplugged so I think it may be the cable Im using that's the problem, cause it keeps acting possessed...
Katsu, I think your right with it grounding out somewere. I rewired it but it still goes off when its tapped so im not to worried about it now, if that's the case, it'll fix its self once I get the PCB worked out and some Proper resistors installed... *knocks on wood*


 
Last edited by a moderator:
Status
Not open for further replies.
Back
Top