Arduino MIDI doesn't start without USB connected.

Hi all,

I have an Arduino NG board. I’ve made it into a midi controller, with a variable resistor and a single switch.

I am powering the Arduino NG from external power. The problem is that I plug it in to wall power, and the board blinks once, but does not initialize the serial chip. If I plug it into USB, even for a short time, the serial chip comes alive and the board produces serial MIDI data.

Does anyone have an idea of how to fix this?

I used Tom Igoe’s MIDI code from the ITP website, and modified it to output pitch bend messages like this:

// The switch is on Arduino pin 10:
#define switchPin 10
// Middle C (MIDI note value 60) is the lowest note we'll play:
//#define middleC 60
//  Indicator LED:
#define LEDpin 13

// Variables: 
char middleC = 0;            // The MIDI note value to be played
int AnalogValue = 0;           // value from the analog input
int lastNotePlayed = 0;   // note turned on when you press the switch
int lastSwitchState = 0;  // state of the switch during previous time through the main loop
int currentSwitchState = 0;
char pitchBend = 0; //i hope this fucker works

void setup() {
  //  set the states of the I/O pins:
  pinMode(switchPin, INPUT);
  pinMode(LEDpin, OUTPUT);
  //  Set MIDI baud rate:
  Serial.begin(31250);
  blink(3);
}

void loop() {
  //  My potentiometer gave a range from 0 to 1023:
  AnalogValue = analogRead(0);
  //  convert to a range from 0 to 127:
  pitchBend = AnalogValue/8;
  currentSwitchState = digitalRead(switchPin);
  // Check to see that the switch is pressed:
  if (currentSwitchState == 1) {
    //  check to see that the switch wasn't pressed last time
    //  through the main loop:
      noteOn(0xE0, 0x40, pitchBend);
    if (lastSwitchState == 0) {
      // set the note value based on the analog value, plus a couple octaves:
     // note = note + 60;
      // start a note playing:
      noteOn(0x90, middleC, 0x40);

      // save the note we played, so we can turn it off:
      lastNotePlayed = middleC;
      digitalWrite(LEDpin, HIGH);
    }
  }
    else {   // if the switch is not pressed:
    //  but the switch was pressed last time through the main loop:
    if (lastSwitchState == 1) {
      //  stop the last note played:
      noteOn(0x90, lastNotePlayed, 0x00);
      digitalWrite(LEDpin, LOW);
    }
}

  //  save the state of the switch for next time
  //  through the main loop:
  lastSwitchState = currentSwitchState;
}

//  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(char cmd, char data1, char data2) {
  Serial.print(cmd, BYTE);
  Serial.print(data1, BYTE);
  Serial.print(data2, BYTE);
}

// Blinks an LED 3 times
void blink(int howManyTimes) {
  int i;
  for (i=0; i< howManyTimes; i++) {
    digitalWrite(LEDpin, HIGH);
    delay(100);
    digitalWrite(LEDpin, LOW);
    delay(100);
  }
}

See the first question in the troubleshooting guide.

Agh! Apologies for not looking hard enough. I did search the forums and Google, but I didn't find/read the troubleshooting guide.

Thanks.

Hey there,

Just wondering how your code ever panned out. I'm doing something similar with a ribbon pot I got from Spectrasymbol, trying to make a homemade ribbon controller for pitch ala theremin/tannerin/french connection/persephone style. But obviously, using regular midi data sent will result in the notes stepping instead of gliding.

Now I do have analog gear, and I can set the slew rate for portamento just enough to remove the stepping sound... But i'm curious as to how well it will work.

I'm going to test it out on a minimax ASB minimoog box and post on here my results.

It did work for me after a bit of tweaking. Unfortunately, I don't have the final code anymore -- the hard drive it was on died. But you can definitely get it to work, yes. I used a single button as a "key" and then sent pitch bend data.

Sorry this isn't more helpful.