top of page

​

boolean sound0playing = false;
boolean sound1playing = false;
boolean sound2playing = false;
boolean sound3playing = false;
boolean sound4playing = false;
boolean sound5playing = false;

void setup() {
  // Set MIDI baud rate:
  Serial.begin(31250);
}

void loop() {

   
  // PLAY: play 
  if (!sound0playing && analogRead(0) <= 500) {
    noteOn(0x90, 0x18, 0x45);
    sound0playing = true;
  }

  //TURN OFF: Note on channel 1 (0x90), some note value (note), silent velocity (0x00):
  if (sound0playing && analogRead(0) > 500) {
    noteOn(0x90, 0x18, 0x00);
    sound0playing = false;
   }

    // PLAY: play 
  if (!sound1playing && analogRead(1) <= 500) {
    noteOn(0x90, 0x19, 0x45);
    sound1playing = true;
  }

  //TURN OFF: Note on channel 1 (0x90), some note value (note), silent velocity (0x00):
  if (sound1playing && analogRead(1) > 500) {
    noteOn(0x90, 0x19, 0x00);
    sound1playing = false;
  }

  // PLAY: play 
  if (!sound2playing && analogRead(2) <= 500) {
    noteOn(0x90, 0x1A, 0x45);
    sound2playing = true;
  }

  //TURN OFF: Note on channel 1 (0x90), some note value (note), silent velocity (0x00):
  if (sound2playing && analogRead(2) > 500) {
    noteOn(0x90, 0x1A, 0x00);
    sound2playing = false;
  }

  // PLAY: play 
  if (!sound3playing && analogRead(3) <= 500) {
    noteOn(0x90, 0x1B, 0x45);
    sound3playing = true;
  }

  //TURN OFF: Note on channel 1 (0x90), some note value (note), silent velocity (0x00):
  if (sound3playing && analogRead(3) > 500) {
    noteOn(0x90, 0x1B, 0x00);
    sound3playing = false;
  }
  
  // PLAY: play 
  if (!sound4playing && analogRead(4) <= 500) {
    noteOn(0x90, 0x1C, 0x45);
    sound4playing = true;
  }

  //TURN OFF: Note on channel 1 (0x90), some note value (note), silent velocity (0x00):
  if (sound4playing && analogRead(4) > 500) {
    noteOn(0x90, 0x1C, 0x00);
    sound4playing = false;
  }

  // PLAY: play 
  if (!sound5playing && analogRead(5) <= 500) {
    noteOn(0x90, 0x1D, 0x45);
    sound5playing = true;
  }

  //TURN OFF: Note on channel 1 (0x90), some note value (note), silent velocity (0x00):
  if (sound5playing && analogRead(5) > 500) {
    noteOn(0x90, 0x1D, 0x00);
    sound5playing = false;
  }
  

}

// plays a MIDI note. Doesn't check to see that cmd is greater than 127, or that
// data values are less than 127:
void noteOn(int cmd, int pitch, int velocity) {
  Serial.write(cmd);
  Serial.write(pitch);
  Serial.write(velocity);
}

Screenshots of the MAX patch used to automate the lighting and the Arduino coding.

bottom of page