Remote Xbee Fireworks Activator

Hey everyone
In preparation for this year's Independence Day, I was planning on making some sort of remote fireworks ignition system. Unfortunately, I am not very experienced with Arduinos and I am not sure if this is a feasible project and am looking for some help, specifically for the receiver Arduino code. So far, I was planning on having a master key switch for arming/disarming the entire system, some status LEDs, a sparkfun LCD screen, push button switches, an xbee and Arduino on the sender side. The receiver side would consist of another arduino, another xbee, 4 relays attached to 4 separate fuse activation devices. The idea was that if the master key switched was closed, and one of the push buttons was pressed, the sender Arduino would send some sort of serial information that the receiver Arduino would decode and activate the corresponding relay.

I wrote and tested the sender code first, which seems to work fine. If the key is turned (switch closed), and I press one of the push buttons, I could actually see the second Xbee recieving the sent data on a connected computer's serial terminal. I don't know what to do from here, any help on the receiver code would be greatly appreciated :slight_smile:

Thanks! :wink:

I got the code for the sparkfun LCD screen from somewhere on the arduino playground and it works fine

//Sender Arduino Code
//LCD screen definition and setup code ---------------
#include <SoftwareSerial.h>
#define txPin 2
SoftwareSerial LCD = SoftwareSerial(0, txPin);
// since the LCD does not send data back to the Arduino, we should only define the txPin
const int LCDdelay=10;  // conservative, 2 actually works

// wbp: goto with row & column
void goTo(int row, int col) {
  LCD.print(0xFE, BYTE);   //command flag
  LCD.print((col + row*64 + 128), BYTE);    //position 
  delay(LCDdelay);
}
void clearLCD(){
  LCD.print(0xFE, BYTE);   //command flag
  LCD.print(0x01, BYTE);   //clear command.
  delay(LCDdelay);
}
void backlightOn() {  //turns on the backlight
  LCD.print(0x7C, BYTE);   //command flag for backlight stuff
  LCD.print(157, BYTE);    //light level.
  delay(LCDdelay);
}
void backlightOff(){  //turns off the backlight
  LCD.print(0x7C, BYTE);   //command flag for backlight stuff
  LCD.print(128, BYTE);     //light level for off.
   delay(LCDdelay);
}
void serCommand(){   //a general function to call the command flag for issuing all other commands   
  LCD.print(0xFE, BYTE);
}

// END Serial LCD Setup code
//------------------------------------------------------------------------------------------------

#define KeyArmLED 13   //Armed status LED
#define KeyArmLED2 12  //Disarmed status LED
#define KeyArm 7       //Key Switch for Arming
#define FireButton1 3  //Button 1 for activating relay 1 on the reciever side
#define FireButton2 4  //Button 2 for activating relay 2 on the reciever side
#define FireButton3 5  //Button 3 for activating relay 3 on the reciever side
#define FireButton4 6  //Button 4 for activating relay 4 on the reciever side     
#define FireLED1 8     //Status LED indicating Button 1 has been pressed and Master Key switch is armed
#define FireLED2 9     //Status LED indicating Button 2 has been pressed and Master Key switch is armed
#define FireLED3 10    //Status LED indicating Button 3 has been pressed and Master Key switch is armed
#define FireLED4 11    //Status LED indicating Button 4 has been pressed and Master Key switch is armed

int val = 0;
int old_val = 0;
int val2 = 0;    
int val3 = 0;
int val4 = 0;
int val5 = 0;


void setup () { 
  Serial.begin(9600);
  pinMode(FireButton1, INPUT);
  pinMode(FireButton2, INPUT);
  pinMode(FireButton3, INPUT);
  pinMode(FireButton4, INPUT);
  pinMode(KeyArm, INPUT);
  pinMode(KeyArmLED, OUTPUT);
  pinMode(KeyArmLED2, OUTPUT);
  pinMode(FireLED1, OUTPUT);
  pinMode(FireLED2, OUTPUT);
  pinMode(FireLED3, OUTPUT);
  pinMode(FireLED4, OUTPUT);
  //Serial LCD setup ------------->
  pinMode(txPin, OUTPUT);
  LCD.begin(9600);
  clearLCD();
  goTo(0,0);
  LCD.print("System Powered  Successfully!");
  delay(5000);
  clearLCD();
  goTo(0,0);
  LCD.print("System Disarmed!-Safe to handle-");
  digitalWrite(KeyArmLED2, HIGH);
  
}
  
//Begin Loop Code Here -------------------------------------------------------

void loop () {
  
// The following checks to see if the master key switch is closed(armed) and displays appropriate LCD message and turns on the appropriate LED

val = digitalRead(KeyArm);
if ((val == HIGH) && (old_val == LOW))
  {
    digitalWrite(KeyArmLED, HIGH);
    digitalWrite(KeyArmLED2, LOW);
    clearLCD();
    goTo(0,0);
    LCD.print("--System Armed--Ready to Fire!!!");
  } 
delay(50);
if ((val == HIGH) && (old_val == HIGH))
  {
    digitalWrite(KeyArmLED, HIGH);
  }
delay(50);
if ((val == LOW) && (old_val == HIGH))
  {
    digitalWrite(KeyArmLED, LOW);
    digitalWrite(KeyArmLED2, HIGH);
    clearLCD();
    goTo(0,0);
    LCD.print("System Disarmed!-Safe to handle-");
  }
delay(10);
old_val = val;

//End Master Key Switch Arm Code
//---------------------------------------------

//Start Xbee transmission Code
//Relay 1
val2 = digitalRead(FireButton1);
if ((val2 == HIGH) && (val == HIGH))
  {  
    digitalWrite(FireLED1, HIGH);
    Serial.println("A");
  } else {
    digitalWrite(FireLED1, LOW);
  }
 //Relay 2
val3 = digitalRead(FireButton2);
if ((val3 == HIGH) && (val == HIGH))
  {  
    digitalWrite(FireLED2, HIGH);
    Serial.println("B");
  } else {
    digitalWrite(FireLED2, LOW);
  }
//Relay 3
val4 = digitalRead(FireButton3);
if ((val4 == HIGH) && (val == HIGH))
  {  
    digitalWrite(FireLED3, HIGH);
    Serial.println("C");
  } else {
    digitalWrite(FireLED3, LOW);
  }
//Relay 4
val5 = digitalRead(FireButton4);
if ((val5 == HIGH) && (val == HIGH))
  {  
    digitalWrite(FireLED4, HIGH);
    Serial.println("D");
  } else {
    digitalWrite(FireLED4, LOW);
  }
}         //end entire code

Just don't. The combination of your lack of experience, short timeframe for testing and fireworks is not a good one. Any defect in your system, hardware or software could have disastrous consequences for someone e.g. all too easy for a bug in the code to have someone reloading your display while you think it's set to safe, but isn't & have unintended firings.

edit: more emphasis

I wrote and tested the sender code first, which seems to work fine. If the key is turned (switch closed), and I press one of the push buttons, I could actually see the second Xbee recieving the sent data on a connected computer's serial terminal. I don't know what to do from here, any help on the receiver code would be greatly appreciated

If you are receiving data, determining what you received, and doing something with it is trivial:

void loop()
{
   if(serial.available() > 0)
   {
      int inChar = Serial.read();
      switch(inChar)
      {
         case 'B':
            // Got a B. Do the B thing
            break;
      }
   }
}

Add additional cases for the other letters you send. The "Do the X thing" bit is up to you.

I wrote and tested the sender code first, which seems to work fine. If the key is turned (switch closed), and I press one of the push buttons, I could actually see the second Xbee recieving the sent data on a connected computer's serial terminal. I don't know what to do from here, any help on the receiver code would be greatly appreciated

Having the 'safety' hardware and software control and interlocks in your sending unit is OK and all, but you are not following the fundamental safety requirement that there be safety interlocks and controls at the remote unit, as it's the device that has control of switching an ignition energy source to the firing device. I think you should seek out people with more first hand experience with this kind of application before you attempt to design and build such a unit.

Lefty

There's a good reason why modern remote initiators (purposely changed word) are surprisingly complex these days. There are many an insurgent who are no longer around to debate the merits of these advanced features. Not to mention many NATO/US soldiers who are happy to agree RF noise, when not properly addressed on the RX end, can easily set something off prematurely.

Honestly, in this day and age where Uncle Sam is extremely paranoid, irrational, and on a witch hunt, I don't consider this discussion the least bit wise. I encourage people to not continue this discussion if you live in or plan to visit the US.

And before you pass off my comment as paranoia, understand Uncle Sam has been repeatedly caught placing GPS trackers and wire traces on students solely because of their engineering interests and family background. In fact, its extremely likely, given the right combination of words here, such posts can garner unwanted attention. Sad but true.

This Uncle Sam sounds a pretty unpleasant type.

And before you pass off my comment as paranoia,

My tin foil hat protects me from such paranoia.

Lefty

just because you're paranoid doesn't mean they aren't out to get you!

Hey all, thanks for the replies!

While I agree that this project could potentially lead to a premature ignition on the RX end, I am not very worried considering the worse that can happen is a "winn-dixie" consumer grade firework goes off in my brick-covered back yard, which it is supposed to do anyway. But, I also feel that my opinion can be easily taken as a crazy, inexperienced, misguided kid's opinion, and I completely respect that given that you all are the experts here.

@Gerg, while you do have an interesting opinion, I don't think I fully agree with your point. Especially now when the state of our public debt is making the government lay off thousands, I do not believe that the feds will waste their time (and money) place GPS trackers in student's backpacks, or search through forum posts looking for potential "threats". Not to mention, the things you speak of can easily lead to legal action since, without the proper warrant, are infringing upon one's human rights. If one were looking to do a project with the intended results that are possibly being suggested here, one not need look further than the dozen or so instructables that exist on the subject.

@Wildbill and Retrolefty, Thank you for your inputs, I was planning on having some sort of safety feature on the RX side, perhaps a simple toggle switch that is toggled after all fireworks have been placed and people (except me) are far enough away.

I will stop the project here considering that I can just walk a few feet and "manually" light the fuse, the way they were intended to do. + Time is becoming an issue. I think I just got carried away with the fun I was having.

Diplo:
@Gerg, while you do have an interesting opinion, I don't think I fully agree with your point. Especially now when the state of our public debt is making the government lay off thousands, I do not believe that the feds will waste their time (and money) place GPS trackers in student's backpacks, or search through forum posts looking for potential "threats". Not to mention, the things you speak of can easily lead to legal action since, without the proper warrant, are infringing upon one's human rights. If one were looking to do a project with the intended results that are possibly being suggested here, one not need look further than the dozen or so instructables that exist on the subject.

Then you've not bothered to follow the news. This isn't some imagined paranoia cooked up in my head. I'm sorry if you're under such a false impression. Its in fact, standard operating procedure these days. In various states its currently being argued about the constitutionality of warrant-less GPS tracking. In some states it has been deemed completely legal. And its become an issue specifically because its so extremely prevalent; though generally only after discovery of the device. They've arrested and illegally held people for simply carrying Estes rocket motors, with absolutely no other evidence or even cause for suspicion. So you'll have to forgive me if I'm conservative in my factually, well supported view. Things are not right and we're not far from welcoming back the days of McCarthyism; though on a different platform.

The simple truth of the matter is, Uncle Sam is irrational, paranoid, on a witch hunt, and thinks nothing of tracking people, without warrants, obtaining illegal wire taps (also been widely covered and documented by the government itself), so on and so on. These are some of the reasons why people unknowingly wind up on black lists and no fly lists. As such, discussion of a remote triggering/detonation device in public, IMOHO, is far from the wisest thing to do given the current insanity.

Sorry, I'm honestly not trying to start a political thread here, but the topic, IMOHO it deserves due caution. Ignore it at you're own, well documented, risk.

Gerg, I am not totally disagreeing with you. The reason I semi-agree with you is because I do in fact "bother" to follow the news and I am aware of the unconstitutional breaches of personal freedoms that the media does bring to light. I admit that this does, from time to time, give me the goosebumps. But, I understand that this new era of national threat has incubated, as you call it, a different platform of McCarthyism, and it is all not that bad. It is true that in post 9/11 times, we need to be a bit more secure which in turn may lead to a few more cases of unconstitutional breaches. You seem to have given up, all though, on the countless agencies and politicians that fight constantly to preserve our freedoms, even in times such as these. Who knows, maybe McCarthy did prevent a communist takeover.

Now, it may seem as if I am going against my previous post. But this is where our opinions differ. People who end up on no-fly lists and in interrogation rooms for no reason do not come from forums such as these asking a simple innocent question. There most likely is a questionable past or other evidence (that is not shed to the public) to these people, which I for one, do not have. So while I believe you are correct on most of your points, I think there is an extra bit of paranoia that is pushing your post over the edge.

But, if I do end up with a tracking device on my car, I'll be sure to PM you.

Sorry for continuing the political post, I'll stop here..Thanks again for all the advice guys.

In various states its currently being argued about the constitutionality of warrant-less GPS tracking. In some states it has been deemed completely legal.

Have you ever considered that it might be constitutional ? You may not like it and not agree with existing judgements, but you are not the one that gets to decide on if something is legal or not, only the courts get that authority.

I know we have certain specified constitutional protections in our homes (warrant required) but it's not clear to me that tracking someone in public is unconstitutional ? I have had cops follow me for several blocks at time through several turns before turning off, I'm sure he/she was checking out my plates for warrants/etc., was that a violation of my rights? Was he not 'tracking' me for some governmental purpose? Has every private investigator ever hired to track someone for a client, violating the rights of the person being tracked?

I'm sorry, but your anti-government/authority attitude seems to me to be too biased for any serious discussion about the actual laws and rights you are addressing.

Lefty

retrolefty:

In various states its currently being argued about the constitutionality of warrant-less GPS tracking. In some states it has been deemed completely legal.

Have you ever considered that it might be constitutional ? You may not like it and not agree with existing judgements, but you are not the one that gets to decide on if something is legal or not, only the courts get that authority.

Yes, I have considered it. And it may very well be. Poplar opinion is that its not. But as you rightly point out, popular opinion is for creation of laws, not enforcement of laws. IIRC, two states have said it is legal. One state has said its not. Most states are simply keeping their heads down and pretending its not taking place. Beyond that, you're ignorantly injecting opinion which I never asserted and assigning it to me. The simple fact is, I didn't assert an opinion one way or the other. You, asserted an opinion for me. My characterization was of their general disposition, not of this specific action.

retrolefty:
I know we have certain specified constitutional protections in our homes (warrant required) but it's not clear to me that tracking someone in public is unconstitutional ? I have had cops follow me for several blocks at time through several turns before turning off, I'm sure he/she was checking out my plates for warrants/etc., was that a violation of my rights? Was he not 'tracking' me for some governmental purpose? Has every private investigator ever hired to track someone for a client, violating the rights of the person being tracked?

Except its far more complex than the simple view you're presenting. If you bother to actually read what I said, your comments are very much on a tangent and making wild assumptions about my position. The generalized issue isn't one of tracking, which I don't have issue with. The issue is one of wide spread, warrant-less tracking, which can go places which can be illegal for an agent to go. Basically they've created a way to potentially violate constitutional protections while avoiding oversight. Regardless, you seem to have completely missed the point. The point is, its not that its legal or illegal, without any regard for my opinion of it, its that the government is acting extremely paranoid, which has and will persecute completely innocent people simply because they can. This is called tyranny and based on your comment, something you entirely endorse. Scary.

retrolefty:
I'm sorry, but your anti-government/authority attitude seems to me to be too biased for any serious discussion about the actual laws and rights you are addressing.

Hate to burst your bubble, but my leanings absolutely are not anti-government. The fact that is your take on my comments is as equally scary as it is bizarre. Unless you're currently standing in line to be illegally detained, such a comment is hypocritical at best. Seriously, your response rings loudly of those pro-McCathery'ners so many years ago. There is a vast, vast difference between anti-government and responsible citizen. The fact you're so easily confused further endorses a new era of McCarthyism is closer than we think. Far, far closer than I ever feared.

Since the point seems to have been completely missed and people are now rushing to assert things I never said nor implied, I'll be very, very clear. Since 9/11 he government is well established at breaking its own laws to the detriment of constitutional rights and well established laws. That's fact. Publicly designing a remote detonation system is iffy at best in such a climate. Besides, using one likely requires a pyro license. Innocent people have been persecuted for doing far less; in fact, nothing. Both the FBI and NSA are on record starting these types of technical forums are high on their watch lists. People are added to black lists and no fly lists for non-disclosed reasons all the time. Good luck getting off one of those lists. Seriously, it almost never happens unless you're in politics or big business. Which questions, is years of legal issues, potentially hundreds of thousands of dollars in legal fees, loss of your job, black listing, and a criminal record, even if its 0.1% of a chance, worth five minutes of fun? Any reasonable person will say no, but its your risk, no matter how small, to assume.

I will add, the general tone of your reply strongly hints that you know very little of the current state of things in the US. Seriously, if you're not at least a very tiny bit scared of the government right now, you don't know anywhere near as much as you like to pretend you do. And contrary to your assertion, being knowledgeable about this topic, makes one a responsible citizen, not anti-government. Frankly, I find your flipped and irresponsible characterization insulting.

Lets just agree to disagree. If you are looking for agreement with your opinions you might find more support at http://www.dailykos.com/

We have probably hijacked this thread more then it deserves, so I will not post further. The Bar Sport section is avalible if you wish.

Lefty

I honestly don't know to what you just disagreed. I offered well documented fact. You disagreed. What?!

Tell you what. Call up your local FBI office and explain to them you plan on creating a remote detonation device and that you would like to collaborate with others in the public and see what their take is on it. Hell, you might even try your local police department. Don't say you're were not warned. But thankfully, you disagreed with them.