ALEX PREGEL SOUND DESIGN
  • Home
  • About
    • Resume
    • Contact Me
  • Productions
  • Projects


​

Custom Qlab Go Box using Arduino

For my "show control" class project, I created a Qlab go-box. First, I drafted the box itself in vectorworks and had it 3D printed. From there, I installed the buttons and wired everything together. Inside there are two prototype boards: the first has a bunch of pull-down resistors and the second contains two Teensy LC boards. The nine buttons are used to control either Qlab (via Midi) or functions within the box itself. The first iteration of the box contained from left to right a arm button, go, panic, up, down, primary Qlab, secondary Qlab, Aux 1, and Aux 2. The arm button is a safety that must be pressed in conjunction with the go or panic button. This function can also be disabled by pressing the first and last buttons for 3 seconds. Once disabled, the "go" and "panic" buttons will send midi without the "arm button" having to be held. The next section shows the code that was uploaded to the Teensy boards.

The Code:

​​int pushButton1 = 0;
int pushButton2 = 1;
int pushButton3 = 2;
int pushButton4 = 3;
int pushButton5 = 4;
int pushButton6 = 5;
int pushButton7 = 6;
int pushButton8 = 7;
int pushButton9 = 8;
int arrayOne[9]= {0,0,0,0,0,0,0,0,0};
int arrayTwo[9]= {pushButton1,pushButton2,pushButton3,pushButton4,pushButton5,pushButton6,pushButton7,pushButton8,pushButton9};
int arrayThree[9]= {0,0,0,0,0,0,0,0,0};
int arrayFour[9]= {0,0,0,0,0,0,0,0,0};
int arrayFive[9]= {0,0,0,0,0,0,0,0,0};
int armState = 0;
int armCount = 0;
int arraySix[20]= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int arrayMidi[9]= {1,2,3,4,5,6,7,8,9};

void setup() {
 Serial.begin(115200);
 //Setup Pins
 for (int i=0; i<=8; i++)
 {
  pinMode(i, INPUT);
 }
}

void loop() {
  for (int i=0; i<=8; i++) //Get initial State
    {
     arrayOne[i] = digitalRead(arrayTwo[i]);
    }
    for (int i=0; i<=8; i++) //Look for Bounce by adding delay and re-cheking state
    {
      if (arrayOne[i]== 1)// If button was pressed
      {
        delay(10);
        arrayThree[i]=digitalRead(arrayTwo[i]); //Read New value of button after delay
        if (arrayThree[i]==arrayOne[i]) //If Value before/after delay maches, do nothing
        {}
        else
        {
          arrayOne[i]=0; //If Value does not match, set putton value to 0
        }
      }
      else{}
    }
     for (int i=0; i<=8; i++) //Look for Change in State
     {
     if (arrayOne[i]==0)// Wait to re-arm button using arrayFive until button has been de-pressed
     {
     arrayFive[i]=1;

     }
     else {}  //if button is currently pressed, do nothing.
     }
 
 //Arm/Disarm Arm Button
 if (arrayOne[0]== 1 && arrayOne[8]==1 && arrayFive[8]==1) //Check to see if First and Last buttons are pressed and if the last button is a new press
  {
  Serial.println();
  Serial.print("Current Count: ");
  arrayFive[8]=0;
  armCount=0;  // reset arm count
  for (int i=0; i<=19; i++) //reset arraySix
  {
    arraySix[i]=0;
  }
  while (arrayOne[8]== 1 && arrayOne[0]== 1 && armCount<= 19)// continue loop while button is held for 5 seconds
  {
    if(digitalRead(pushButton1)== 0)// If Button 1 is released, exit loop
    {
      arrayOne[0]= 0;
    }
    if(digitalRead(pushButton9)== 0)// If Button 9 is released, exit loop
    {
      arrayOne[8]= 0;
    }
    arraySix[armCount]=1; //Write a 1 to the array for every time the loop completes
    armCount++; //Increase the armCount with each repeat
    delay(100);
    Serial.print(armCount);
    Serial.print(" ");
  }
  armCount = 0; //reset arm count
  for (int i=0; i<=19; i++) //Check if button was released during the three seconds
  {
    armCount= (arraySix[i]+armCount); //Get sum of array
  }
  Serial.println();
  Serial.print("Check Array: ");
  Serial.print(armCount);
  if (armCount== 20 && armState == 0) //turn arm On if loop completed 20 times
  {
  armState= 1;
  Serial.println();
  Serial.print("Arm On");
   usbMIDI.sendNoteOn(1, 127, 2);
  }
  else if (armCount==20 && armState == 1) //turn arm off if loop completed 20 times
  {
  armState = 0;
  Serial.println();
  Serial.print ("Arm Off");
   usbMIDI.sendNoteOn(2, 127, 2);
  }
  else                            //If arm did not complete
  {
  Serial.println();
  Serial.print ("Arm Failed");
  }
 }
//Start of MIDI Messages
if (arrayOne[0]== 1 && arrayOne[1]== 1 && arrayFive[1]==1) //Go
 {
 arrayFive[1]=0; //Tell that messaged fired and to not repeat until button is de-pressed
 usbMIDI.sendNoteOn(arrayMidi[0], 127, 1);
 Serial.println();
 Serial.print("Midi Sent to Go");
 }
if (arrayOne[0]== 1 && arrayOne[2]== 1 && arrayFive[2]==1) //Panic
 {
 arrayFive[2]=0; //Tell that messaged fired and to not repeat until button is de-preseed
 usbMIDI.sendNoteOn(arrayMidi[1], 127, 1);
 Serial.println();
 Serial.print("Midi Sent to Panic");
 }
for (int i=3; i<=8; i++)
 {
 if (arrayOne[i]== 1 && arrayFive[i]== 1) //Other Midi for buttons 4-9
 {
  arrayFive[i]=0; //Tell that messaged fired and to not repeat until button is de-pressed
  usbMIDI.sendNoteOn(arrayMidi[(i-1)], 127, 1);
  Serial.println();
  Serial.print("Midi Sent for Button: ");
  Serial.print(i+1);
 }
 }
 armCount=0; //arm Count Safe
}
Powered by Create your own unique website with customizable templates.
  • Home
  • About
    • Resume
    • Contact Me
  • Productions
  • Projects