Go Down

Topic: Arduino MIDI Controller Not Working Properly with Serial-MIDI Converter (Read 1 time) previous topic - next topic

xiwi

Hi,

So, I'm building a MIDI controller and I've given up trying to make it appear as an HID MIDI device. I'm new to this and feel uncomfortable with DFU and AVR-ISP programmers. I'm using an Uno R3 with 16u2 chip. Does anyone have a good link for this? I have access to another UNO to act as an ISP.

I've written this code, which is could be tighter, and am trying to get it to function properly using Serial-MIDI Converter (http://www.spikenzielabs.com/SpikenzieLabs/Serial_MIDI.html).

I've Serial-MIDI Converter before with this project (http://www.instructables.com/id/Arcade-Button-MIDI-Controller/step8/Software/) and it worked out just fine. I have MIDI Yoke and use it frequently. My issue must be somewhere in my code or related to the Arduino I'm using.

My RX lights up green when it receives messages at 31250 baud and lights up read when I run it at 115200 baud, but the TX stays unlit in both instances.

Any advice would be incredibly helpful.

Thanks a bunch everyone!

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

byte cc14 = 0;
byte cc02 = 0;
byte cc15 = 0;
byte cc03 = 0;
byte cc16 = 0;
byte cc04 = 0;
byte cc17 = 0;
byte cc05 = 0;
byte cc18 = 0;
byte cc06 = 0;
byte cc19 = 0;
byte cc08 = 0;
byte cc20 = 0;
byte cc09 = 0;
byte cc21 = 0;
byte cc12 = 0;
byte cc22 = 0;
byte cc13 = 0;

int AnalogValue00 = 0;
int AnalogValue01 = 0;
int AnalogValue02 = 0;
int AnalogValue03 = 0;
int AnalogValue04 = 0;
int AnalogValue05 = 0;
int AnalogValue06 = 0;
int AnalogValue07 = 0;
int AnalogValue08 = 0;
int AnalogValue09 = 0;
int AnalogValue10 = 0;
int AnalogValue11 = 0;
int AnalogValue12 = 0;
int AnalogValue13 = 0;
int AnalogValue14 = 0;
int AnalogValue15 = 0;
int AnalogValue16 = 0;
int AnalogValue17 = 0;

byte lastAnalogValue00 = 0;
byte lastAnalogValue01 = 0;
byte lastAnalogValue02 = 0;
byte lastAnalogValue03 = 0;
byte lastAnalogValue04 = 0;
byte lastAnalogValue05 = 0;
byte lastAnalogValue06 = 0;
byte lastAnalogValue07 = 0;
byte lastAnalogValue08 = 0;
byte lastAnalogValue09 = 0;
byte lastAnalogValue10 = 0;
byte lastAnalogValue11 = 0;
byte lastAnalogValue12 = 0;
byte lastAnalogValue13 = 0;
byte lastAnalogValue14 = 0;
byte lastAnalogValue15 = 0;
byte lastAnalogValue16 = 0;
byte lastAnalogValue17 = 0;

void setup()
{
  MIDI.begin();
  Serial.begin(115200);
  pinMode(5, OUTPUT); // s0
  pinMode(6, OUTPUT); // s1
  pinMode(7, OUTPUT); // s2 
}

void loop()
{
//Pot 00 - cc14 + Pot 08 - cc18
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
      AnalogValue00 = analogRead(0);
      cc14 = AnalogValue00/8;
      if (lastAnalogValue00 != cc14) {
        MIDI.sendControlChange(14,cc14, 1);
        lastAnalogValue00 = cc14;
      }
     
      AnalogValue08 = analogRead(1);
      cc18 = AnalogValue08/8;
      if (lastAnalogValue08 != cc18) {
        MIDI.sendControlChange(18, cc18, 1);
        lastAnalogValue08 = cc18;
      }     
   
//Pot 01 - cc02 + Pot 09 - cc06   
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
      AnalogValue01 = analogRead(0);
      cc02 = AnalogValue01/8;
      if (lastAnalogValue01 != cc02) {
        MIDI.sendControlChange(2, cc02, 1);
        lastAnalogValue01 = cc02;
      }
     
      AnalogValue09 = analogRead(1);
      cc06 = AnalogValue09/8;
      if (lastAnalogValue09 != cc06) {
        MIDI.sendControlChange(6, cc06, 1);
        lastAnalogValue09 = cc06;
      }   

//Pot 02 - cc15 + Pot 10 - cc19 
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
digitalWrite(7, LOW);
      AnalogValue02 = analogRead(0);
      cc15 = AnalogValue02/8;
      if (lastAnalogValue02 != cc15) {
        MIDI.sendControlChange(15, cc15, 1);
        lastAnalogValue02 = cc15;
      }

      AnalogValue10 = analogRead(1);
      cc19 = AnalogValue10/8;
      if (lastAnalogValue10 != cc19) {
        MIDI.sendControlChange(19, cc19, 1);
        lastAnalogValue10 = cc19;
      }
 
//Pot 03 - cc03 + Pot 11 - cc08
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, LOW);
      AnalogValue03 = analogRead(0);
      cc03 = AnalogValue03/8;
      if (lastAnalogValue03 != cc03) {
        MIDI.sendControlChange(3, cc03, 1);
        lastAnalogValue03 = cc03;
      }
     
      AnalogValue11 = analogRead(1);
      cc08 = AnalogValue11/8;
      if (lastAnalogValue11 != cc08) {
        MIDI.sendControlChange(8, cc08, 1);
        lastAnalogValue11 = cc08;
      }       

//Pot 04 - cc16 + Pot 12 - cc20 
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, HIGH);
      AnalogValue04 = analogRead(0);
      cc16 = AnalogValue04/8;
      if (lastAnalogValue04 != cc16) {
        MIDI.sendControlChange(16, cc16, 1);
        lastAnalogValue04 = cc16;
      }
     
      AnalogValue12 = analogRead(1);
      cc20 = AnalogValue12/8;
      if (lastAnalogValue12 != cc20) {
        MIDI.sendControlChange(20, cc20, 1);
        lastAnalogValue12 = cc20;
      }

//Pot 05 - cc04 + Pot 13 - cc09 
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(7, HIGH);
      AnalogValue05 = analogRead(0);
      cc04 = AnalogValue05/8;
      if (lastAnalogValue05 != cc04) {
        MIDI.sendControlChange(4, cc04, 1);
        lastAnalogValue05 = cc04;
      }
     
      AnalogValue13 = analogRead(1);
      cc09 = AnalogValue13/8;
      if (lastAnalogValue13 != cc09) {
        MIDI.sendControlChange(9, cc09, 1);
        lastAnalogValue13 = cc09;
      } 

//Pot 06 - cc17 + Pot 14 - cc21 
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
      AnalogValue06 = analogRead(0);
      cc17 = AnalogValue06/8;
      if (lastAnalogValue06 != cc17) {
        MIDI.sendControlChange(17, cc17, 1);
        lastAnalogValue06 = cc17;
      }     
     
      AnalogValue14 = analogRead(1);
      cc21 = AnalogValue14/8;
      if (lastAnalogValue14 != cc21) {
        MIDI.sendControlChange(21, cc21, 1);
        lastAnalogValue14 = cc21;
      }   
   
//Pot 07 - cc05 + Pot 15 - cc12
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
      AnalogValue07 = analogRead(0);
      cc05 = AnalogValue07/8;
      if (lastAnalogValue07 != cc05) {
        MIDI.sendControlChange(5, cc05, 1);
        lastAnalogValue07 = cc05;
      }
     
      AnalogValue15 = analogRead(1);
      cc12 = AnalogValue15/8;
      if (lastAnalogValue15 != cc12) {
        MIDI.sendControlChange(12, cc12, 1);
        lastAnalogValue15 = cc12;
      }
     
      AnalogValue16 = analogRead(2);
      cc22 = AnalogValue16/8;
       if (lastAnalogValue16 != cc22) {
        MIDI.sendControlChange(22, cc22, 1);
        lastAnalogValue16 = cc22;
      }
       
      AnalogValue17 = analogRead(4);
      cc13 = AnalogValue17/8;
       if (lastAnalogValue17 != cc13) {
        MIDI.sendControlChange(13, cc13, 1);
        lastAnalogValue17 = cc13;
      }
  delay(3);
}

Go Up