Hi,
I have recently purchased an Arduino Mega, with the view of using it to control a firework show on November 5th at home.
My concept is to have a firing panel :
From this i am hoping to use the Arduino to control relays via the digital outputs, to switch 18V across the ignitors for the fireworks.
I have been reading through a few threads on the net where others have done similar things using Arduino, and i have got some ideas for coding and usage, I am hoping what i wish to achieve is actually possible.
I would like to use this code on each level of my firing system menu:
#include <stdio.h>
#include <stdlib.h>
// Written by: Steve Ries http://steveries.com on 2/23/12 Rev v1.1
// Please feel free to change and distribute freely, however I do ask that these credits remain intact
// Only ADD to the credits if you ADD code, but NEVER REMOVE anyones credits.
// Thanks ~Steve~
// Define Global Vars and Sets up unit for your particular hardware
// Set this number to your Start Fire Input Pin
#define StartFire 0
// Set this number for your TOTAL number of Firing Ques in the system, 0 does not count as a number here. 13 means 13 (ALSO HAS NO RELATION TO ANY PIN NUMBERS AT ALL).
int NumCues = 13;
// Define ALL your Output pins, and WHAT ORDER THE PINS FIRE IN! You must have exactly the same number of these as you have NumCues defined above
int PinFireOrder[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
// Define ALL your Delays BETWEEN each Pin. IE: The first delay number here is wedged after Que 1 fires and before Que 2 starts
// So TOTAL you should have 1 less than your TOTAL Number of ques, Because there is no delay before Que1 and No Delay after the Last Que (Only in between Ques)
// Delay times are in Miliseconds, There's 1000 ms in 1 Second (IE: 500 is 1/2 Second)
int PinFireDelay[] = {500, 200, 500, 200, 500, 200, 500, 200, 500, 200, 500, 200};
// Set this to your desired Firing Output (Pulse) Time in ms (This time MUST complete before the PinFireDelay Time STARTS to count down.
// IE: PinFireDelay is set to 500, SO Pin will go high for 250 ms and then start to count down the 500 ms
// Meaning if your que actually lights up in 5 ms into the 250ms pulse, your next que will not fire for 245ms + 500ms = 745ms!!!
int PulseTime = 250;
//All Code Below THIS LINE should NOT be changed or adjusted!!!! (Unless you REALLY know what you are doing!)
int PinSetup = 0; //Dont change this! It's for seting up outputs later in the code
int CurrentPos = 0; // Dont change this!! It's for keeping track of what que the system is on in the sequence
//Declare Pins as Input or Output
void setup()
{
//Sets Sequencer Input as Input
pinMode(StartFire, INPUT);
//Sets all previously defined firing Pins as Outputs
PinSetup = 0;
{pinMode(PinFireOrder[PinSetup], OUTPUT);}
for (PinSetup = 0; PinSetup < (NumCues - 1); PinSetup++)
{pinMode(PinFireOrder[PinSetup], OUTPUT);}
}
// Code for Running the Full Sequence
void StartSeq()
{
// Fires first Que with requested pulse time.
digitalWrite((PinFireOrder[CurrentPos]), HIGH);
delay(PulseTime); // Waits requested pulse time before shutting off pin (Firing)
digitalWrite((PinFireOrder[CurrentPos]), LOW);
// First Que is done, now looks for ques in a loop to fire and delay, until it reaches the max number of ques defined above
// Loop looks to see if any Ques left, if so; then waits requested delay time in between ques, then fires next que for requested pulse time, then loops
for (CurrentPos = 0; CurrentPos < NumCues; CurrentPos++)
{
delay(PinFireDelay[(CurrentPos -1)]); // Waits requested Delay time in between Ques before firing
digitalWrite((PinFireOrder[CurrentPos]), HIGH);
delay(PulseTime); // Waits requested pulse time before shutting off the pin (Firing)
digitalWrite((PinFireOrder[CurrentPos]), LOW);
}
}
//Main Program Loop (Just Keep Looking For Firing Input Until It sees it)
void loop()
{
//Monitor If Fire0 Goes High, Then Start FireNextCue Code
if (digitalRead(StartFire) == HIGH) {StartSeq();}
}
I will maybe have to tweak this for the ground show, as i dont want everything going off to quick and ending up with 10/15 roman candles all running at once…
I need to figure out my firing system menu, and how to code this and include the firing steps.
Any help or guidance would be greatly appreciated.
Moderator edit: quotes swapped for CODE TAGS.