MIDI Controller Stage 2

Posted on November 9, 2015

It works! I had made a couple of foolish errors, due to looking at the wrong pin schematic for the TEENSY (I have 3.2 not 2). But I now have a working, single pot controller. With this mastered I’m hoping that adding more pots should be straight forward. I’d also like to include an LED that flashes on the MIDI clock, this should help me keep time without the need for headphones.

I was impressed at the simplicity of the coding for TEENSY. The snippet below is the entire code. I’m having to smooth the value to reduce noise. Apparently the inclusion of a capacitor will help reduce this.

Looking forward to designing a case..

 

 


#define NUM_PORTS           1
int values[NUM_PORTS][2];

void setup()
{

}

void loop()
{

 for( int i = 0; i < NUM_PORTS; ++i )
 {
   const int prev_value    = values[i][0];
   const int current_value = values[i][1];
   int new_value           = analogRead( A0 ) / 8;

   int blended_value       = ( new_value + current_value + prev_value ) / 3;

   if( prev_value != blended_value )
   {
     Serial.print("analog 0 is: ");
     Serial.print(blended_value);
     Serial.print("n");

     usbMIDI.sendControlChange( 1, blended_value, 1 );
   }

   values[i][0]             = current_value;
   values[i][1]             = blended_value;
 }

 delay(5);

}
Back to Latest Posts
..