Go Down

Topic: Midi on/off Whammy 4 (Read 103 times) previous topic - next topic

bopelado

Hi guys, Im new in this forum and new in arduino.

im using a secuence effect for Whammy 4 with a switch on pin 2, that works as start/stop sequence loop, I would like to disable/enebale effect too, I mean press switch start loop and effect on, press again stop loop effect off.

I have all the sequence except to stop and off effect, it's only stop the loop whle the ffect remains on.

A great guy is helping me but I would like to finsih this, my brian will blow away.

thanks


Code: [Select]
#include <MIDI.h>

MIDI_CREATE_DEFAULT_INSTANCE();

const float TEMPO = 120;
const float DELAY = 60 / TEMPO / 4 * 1000;
const float MIN_TREADLE = 0;
const float MAX_TREADLE = 125;
const int LED = 13;

//here you have to check what interrupt pins your board have and set it
const byte interruptPin = 2; //in some arduino board 2 is an interrupt
volatile byte state = LOW; //this is the variable that if it's TRUE sequence run and if FALSE sequence stop

void setup() {
  pinMode(interruptPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(interruptPin), toggle, FALLING);  //every time you FALL the signal on the button (BUTTON DOWN) execute toggle() function
  pinMode(LED, OUTPUT);
  MIDI.begin();
}

void down()
{
  MIDI.sendProgramChange(3, 1);
  MIDI.sendControlChange(11, MAX_TREADLE, 1);
  delay(DELAY);
}

void normal()
{
  MIDI.sendControlChange(11, MIN_TREADLE, 1);
  delay(DELAY);
}

void up()
{
  MIDI.sendProgramChange(1, 1);
  MIDI.sendControlChange(11, MAX_TREADLE, 1);
  delay(DELAY);
}


void loop() {
  if(state) {
//put here the code of the midi execution of the last sketch, it will be executed only when state is true.

motp();


  }
}

// MUSE - Map of the Problematique
void motp()
{
  digitalWrite(LED, HIGH);
  down();
  digitalWrite(LED, LOW);
  normal();
  up();
  normal();
  up();
  normal();
  down();
  normal();
  up();
  normal();
  up();
  normal();
  down();
  normal();
  up();
  normal();
}


void toggle() {
 
  state = !state;
  midiSendCC(0,0,0); //this is off
  midiSendCC(0,127,0); //this is on
}

void midiSendCC(byte controller, byte value, byte channel) {
  byte a = 0xb;
  byte b = a << 4;
  byte ch = b | channel;
  Serial.write(ch);
  Serial.write(controller);
  Serial.write(value);
}

//interrupt pin allows you to BREAK the program when input change.

Go Up