Go Down

Topic: Help needed for Arduino Drum set-up (Read 1 time) previous topic - next topic

Joeyarduino

#5
May 25, 2011, 09:14 pm Last Edit: May 25, 2011, 10:00 pm by Joeyarduino Reason: 1
Hello,

I'm still struggling with my project.
I finally got my relays set up right and when I test them with the LED on pin 13 they all work fine.
BUT when I connect my board to ardrumo I can't figure out the code I need the get them sorted.
The relays work as push buttons so I need to get rid of all the piezo information.
This is the code for the ardrumo when using piezo's

/*
* Ardrumo sketch
*
* Use with the Ardrumo software here:
* http://code.google.com/p/ardrumo/
* This is designed to let an Arduino act as a drum machine
* in GarageBand (sorry, Mac OS X only).
*/

#define LEDPIN     13     // status LED pin
#define PIEZOTHRESHOLD 5  // analog threshold for piezo sensing
#define PADNUM 6          // number of pads

int val;

void setup() {
  pinMode(LEDPIN, OUTPUT);
  Serial.begin(57600);   // set serial output rate
}

void loop() {

  // Loop through each piezo and send data
  // on the serial output if the force exceeds
  // the piezo threshold
  for(int i = 0; i < PADNUM; i++) {
    val = analogRead(i);
    if( val >= PIEZOTHRESHOLD ) {
      digitalWrite(LEDPIN,HIGH);  // indicate we're sending MIDI data
      Serial.print(i);
      Serial.print(",");
      Serial.print(val);
      Serial.println();
      digitalWrite(LEDPIN,LOW);
    }
  }
}

Is there anybody that is able to adjust the ardumo code that I need to upload to use my switches instead of the piezo's?
I have got resistors between my relays so there is no need in using the internal pull up.

thank you very very much

Joey

Joeyarduino

Hello everybody!
My project is taking shape as we go! I found out (thanks to Mike from ardrumo) that i'm able to use my switches.
Michael helped me writing this code below which wors perfectly.
The only thing I would like to do is add three more switches on digital pin 4, 5 and 6 (i'm using pin 7 right now)
These other switches should turn on other pads (switch 7 switches pad 1)
Hopefully somebody is able to help me writing the right code since I'm lost in my project.

#define LEDPIN     13     // status LED pin
#define SWITCHPIN   7     // switch digital pin
#define CONSVAL   120     // default value to use for trigger

int val;

void setup() {

pinMode(LEDPIN, OUTPUT);
pinMode(SWITCHPIN, INPUT); // assume switch is wired to SWITCHPIN
Serial.begin(57600);       // set serial output rate
}

void loop() {

// If a button connected to digital pin #7 is pressed
// then trigger a sound.  Note this code should include
// some way to make sure the sound is played just once
// and not over and over if a button is held down.

   val = digitalRead(SWITCHPIN);
   if( val == 1 ) {
     digitalWrite(LEDPIN,HIGH);  // indicate we're sending MIDI data
     Serial.print(1);            // send signal to Ardrumo pad 1
     Serial.print(",");
     Serial.print(CONSVAL);
     Serial.println();
     digitalWrite(LEDPIN,LOW);
   }
}


(the coe I'm using right now for pin 7)

Go Up