Marching quad drum project question(s)...

Hello fellow nerds! This is my first post inn this forum, so please go easy on me if I’ve forgotten something. This is also my first project into Arduino, so basic, workable solutions will go a long way.

I’ve tried to outline where my questions are in the text with (#'s), so they’ll be easier to find.

As you can see from the subject line, I am making a portable, triggered drum light for each drum of my son’s quad (4) drum kit for his marching band.

THE PERCEIVED GOAL:

When the drum is hit, I want the LED strands inside the drum to light up for a short period (some fraction of a second) before turning off. I have a set, distinguishable color for each of the four drums… no color changing yet.

THE GRAND VIEW OF THE SETUP:

The piezo I’m planning on is this one: https://www.sparkfun.com/products/9198… looks sensitive, yet strong, like me. It is mounted in contact with the drum head, and it transmits through an over-voltage regulating circuit, (1M ohm resister and a 5v Zener diode) sending essentially an analog signal to the Arduino Nano I’m using.

Once the signal is processed using a variant of the “Knock” script, the Nano will then send a resultant output signal to a 4 channel SSR relay, one for each input, that will then light up the LED strips, which vary in length. I am planning on powering the lights- https://www.sparkfun.com/products/1202 with a separate 12v source from the 5V power to the Arduino, sensors, and SSR.

THE QUESTION:

Using a variation of the Knock program seems to confound the nano. (I’ll attach the code below here. So if I press on “channel 4”, it’ll light up the 4th channel light on the SSR LED, but not light the LED, and it’ll also light up the 1st channel on the SSR. Then the nano" L" LED with rapidly cycle, and then go solid.

I was watching on “the Youtube” under piezo FYI DIY https://www.youtube.com/watch?v=vmeChTAHODQ where she mentions that the Knock program doesn’t handle multiple inputs well, and recommends using the Sparkfun 330 tutorial, which I would like to modify to accommodate 4 individual inputs.

THE QUESTION:

Is there a sketch that already exists for this project? Or how can I modify the code so that I can use it, as well?

I am sure someone else has done this project before, and I’m hoping you may share your advice with the me, the noob. Thank you in advance.

The existing sketch

int piezo_Pin1= A1;
int piezo_Pin2= A3;
int piezo_Pin3= A2;
int piezo_Pin4= A4;
int LED_Pin1= 13;
int LED_Pin2= 2;
int LED_Pin3= 3;
int LED_Pin4= 4;

//Set the threshold levels
int threshold= 200;

//Wakeup the Serial Monitor 
void setup()
{
Serial.begin(9600);
pinMode(LED_Pin1, OUTPUT);
pinMode(LED_Pin2, OUTPUT);
pinMode(LED_Pin3, OUTPUT);
pinMode(LED_Pin4, OUTPUT);
digitalWrite(LED_Pin1, HIGH);
digitalWrite(LED_Pin2, HIGH);
digitalWrite(LED_Pin3,HIGH);
digitalWrite(LED_Pin4, HIGH);
}

//if the reading is higher than the threshold value, then the LED is turned ON for a Second You can edit to your sepecification
void loop()
{
int reading1= analogRead(piezo_Pin1);
int reading2= analogRead(piezo_Pin2);
int reading3= analogRead(piezo_Pin3);
int reading4= analogRead(piezo_Pin4);
//Serial.println(reading);
if (reading1 > threshold)
{
digitalWrite(LED_Pin1, LOW);

}
if (reading2 > threshold)
{
digitalWrite(LED_Pin2, LOW);

}
if (reading3 > threshold)
{
digitalWrite(LED_Pin3, LOW);

}
if (reading4 > threshold)
{
digitalWrite(LED_Pin4, LOW);

}
delay(100);
digitalWrite(LED_Pin1, HIGH);
digitalWrite(LED_Pin2, HIGH);
digitalWrite(LED_Pin3, HIGH);
digitalWrite(LED_Pin4, HIGH);
}

Hi seattlearduino,

While SparkFun Tech Support cannot help debug custom code, a quick look at your code throws up a couple of flags. First, you are defining several variables in your loop which might be why you’re having trouble isolating the inputs and why you’re getting weird errors with the LEDs. Try re-formatting to set your analog inputs, LED pins and the threshold to all be defined before your setup and loop as well as defining them as constant variables since they will not change. Also, set your sensor readings as standard variables before your setup and loop.

I would also recommend getting everything working with 1 input and LED, then move to 2 and so on. That way you can identify where things break down more easily.

Finally, for some tutorials, I would recommend searching around on [Instructables as that is a great site that has a bunch of tutorials for Arduino and other microcontroller projects. Just do a quick search for something like “Arduino Drum Lights” or just “Drum Lights” and that should turn up quite a few tutorials.

I hope this information helps you get moving forward with this project. If you run into any other snags or have any questions about specific SparkFun products in this project, let us know and we would be happy to help as much as we can.](https://www.instructables.com/)

Thank you for getting back to me! I am super impressed with Sparkfun, and the products I got from you. I a m also excited to see that the coded I have “should” work, even with some tweaking. I got a new “lead” for the sketch at GitHub, https://github.com/danmalone326/drumlight but I’ll be honest: it’s way the hell out of my infancy coding skills. I’m going to incorporate your advice here today and see if it helps get my sketch running smoothly. I am working on the project today, and will be using only one channel at a time to see how it works. I will try and post any progress, if there is any. Thanks, and go buffs.