Sunday, 16 September 2012

My DIY Arduino MIDI controller - 7. STUCK! (Help needed)

Ok, so... I've been away for some time because I had to focus on other projects, mostly professional but also musical (released a *free* EP in June, check it out @, it's 6 tracks of melodic electronica!) or vacational:

Florence, Italy

Anyway, I decided I should get back to work on my controller and started to proceed but I got quickly stuck with the next step: sending CC messages, which is kindof essential to a MIDI controller innit...

The problem is this: I'm trying to send CC messages on MIDI channel 1, on control number 16 (I tried various control numbers and got the same problem each time). My software (Reason 6) does receive MIDI data, but I get erratic values on erratic control numbers.

I tried the serial.write command as well as the MIDI Library v3.2, without success. Here is the very simple code, using the library:


// Variables:
int cc = 0;
int AnalogValue = 0; // define variables for the controller data
int lastAnalogValue = 0; // define the "lastValue" variables

void setup() {
  //  launch MIDI

void loop() {
  AnalogValue = analogRead(0);
  //  convert to a range from 0 to 127:
  cc = AnalogValue/8;
  // check if analog input has changed
  if (lastAnalogValue != cc) {
    // update lastAnalogValue variable
    lastAnalogValue = cc;
  }  //  endif

I posted on the Arduino forums but got no useful reply yet, so I thought I might as well tell it here and maybe some charitable soul would post a comment to help me troubleshoot this issue... I did output my sensor value to the serial monitor and it was just as expected, nothing wrong there. Maybe I should use a delay at startup to prevent unwanted current to go to the serial port while the sketch uploads... I'll try that ASAP.

<< Previous: 6. MIDI communication, Part I: Most basic stuff :)