Led strip displaying electronic drum signal

Hello,
First of all i want to say i'm pretty new to Arduino, but i have used other programming 'languages' like flowcode.

My goal is to connect my electronic drum set to my arduino, and whenever you would hit a drumpad the ledstrip has to light up in a color matching the hardness of the stroke. I've looked at other codes and examples and started writing my own code (first time writing my own code). As i expected it doesn't work. I have done a lot of troubleshooting but nothing seems to work. If anyone knows what i'm doing wrong and could point me in the right direction I would be very happy.

I'm using an output on my electronic drumset and used 2 wires to go to my arduino. the 'plus' is wired to the 5v pin and the other wire goes to the A0 pin. The output signal from my drumset is just a sound signal.
Then i use a ledstrip with WS2811 on pin 6 to show the colors. Thats about it.

Thanks in advance for any help! :slight_smile:

sketch_apr11a.ino (1011 Bytes)

If you post the code as described in the how to use this forum sticky more people will see it and be able to offer help.

#include <Adafruit_NeoPixel.h>

#define Signal_Pin A0
#define LED_PIN 6
#define N_PIXELS 30


Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_PIXELS, LED_PIN, NEO_GRB + NEO_KHZ800);

int sensorPin = A0;
int LED = 6;
int sensorValue = 0;


void setup() 
{
    strip.begin();
    strip.show();  
    pinMode (LED, OUTPUT);
    pinMode (sensorPin, INPUT);
      
}

void loop() 
{

sensorValue = analogRead(sensorPin); 
if ((sensorValue>255)&& (sensorValue < 455))
    {
      strip.Color(0,255,0);
      strip.show();
      delay(1000);
      strip.Color(0,0,0);
      strip.show();
    }
 
else if ((sensorValue>456) && (sensorValue <754))
    {
      strip.Color(0,0,255);
      strip.show();
      delay(1000);
      strip.Color(0,0,0);
      strip.show();
    }

else ((sensorValue>755) && (sensorValue < 1024));

    {
      strip.Color(255,0,0);
     strip.show();
      delay(1000);
      strip.Color(0,0,0);
      strip.show();      
    }   
}

I'm using an output on my electronic drumset and used 2 wires to go to my arduino. the 'plus' is wired to the 5v pin and the other wire goes to the A0 pin.

Is there a common ground between the drum set and the Arduino? Which Arduino? Can you post a schematic of your wiring? Do you have a manual or schematic for the drum set that shows how to use the output?

" The output signal from my drumset is just a sound signal."

Of course it is a sound signal, it's for your headset.

Paul

I'm using an output on my electronic drumset and used 2 wires to go to my arduino. the 'plus' is wired to the 5v pin and the other wire goes to the A0 pin

The drum ground should be connected to the Arduino ground with the analog audio signal going to the Arduino's analog input.

The Arduino's input should be biased at 2.5V because the Arduino can't read the negative half of the AC audio signal. In fact, it can be damaged by negative voltages and/or the audio can be "damaged" (distorted). The standard bias circuit is attached to the bottom of [u]this post[/u]. (That's a different-simpler effect but you may also want to steal some ideas from the code.)

If you haven't already done so, I recommend you run the Analog Read Serial Example to see what kind of readings you're getting so you can set your thresholds. (Take-out the delay.)

With the bias, silence will read about 512 but if you wish you can subtract-out the bias to get positive and negative values. Note that you are reading/sampling a waveform that crosses-through zero twice per cycle and is positive half the time and negative half the time (ignoring or subtracting the bias). So, your readings will "look random" except you'll get some bigger positive & negative readings with loud sounds.

Note that you're not reading the input during delay() and those delays are going to "kill you" because you'll mostly miss the drum hits. You'll just get one of those "random" readings for an instant between delays and you could easily be reading at (or near) a zero-crossing.

Hello,
first of all, thanks for the replies! second of all, i can't post pictures here since the file size is to big.

I don't think i need to set the voltage of the arduino to 2.5V or need to change any of the wiring. I used another code wich used a microphone to control the led strip. The more sound the more the light would 'dance'. I then changed the microphone to the signal of my drumset and it worked just fine (except for the lightning effects ofcourse). So i don't think the wiring is wrong or should cause any issues. I think i overlooked something while writing the code or did something wrong as i'm new to arduino. so my question is; can anyone help me find my mistake or tweak the code so it would work or point me in the right direction.
i'm also using an arduino mega
Thanks