Go Down

Topic: drum kit arduino mega 2560 (Read 819 times) previous topic - next topic


Hello, my name is Sylvain, I am in the objective to create an drum kit midi wicht arduino mega 2560.
I need you, because I try to use my pedal of sustain, to close my hi-hat. I have to find on your forum a code, but I try to add it the swicht.
Could you help me?
Exemple: (A0, is my hi-hat...)

Thank you!

#define  MAX_PIEZO  9

uint8_t piezo[MAX_PIEZO] = { A0, A1, A2, A3, A4, A5, A6, A7, A8 };
uint8_t drumType[MAX_PIEZO] = { 9, 8, 7, 6, 5, 4, 3, 2, 1 };

const int threshold = 500; 

void setup()
  for (uint8_t i=0; i<MAX_PIEZO; i++)
    pinMode(piezo, INPUT);


void MidiTX(unsigned char StatusByte, unsigned char Note, unsigned char Val)

void ProcessPiezo(uint8_t p)
  uint16_t sensorReading = analogRead(piezo[p]);
  uint16_t  val;

  if (sensorReading > threshold)
    uint32_t oldcas = millis() + 5;
    // this part of the code looks complex
    // explain what you are trying to do?
    while (analogRead(piezo[p]) > threshold)
      if (millis() >= oldcas)
        val = analogRead(piezo[p]) / 9;
    MidiTX(144, drumType[p], val);
    MidiTX(128, drumType[p], val);

void loop()
  for (uint8_t i=0; i<MAX_PIEZO; i++)

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131