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);
}