Hi, Ive been trying to get a simple verified midi-in sketch running for days. It does not recieve or read incoming midi data. My hardware is good and connected properly. the arduino loads and executes other sketches with no problem. I am begining to think it my be a problem with the ATMEGA itself or software. Here's the sketch:
//variables setup
byte incomingByte;
int statusLed = 13; // select the pin for the LED
//setup: declaring iputs and outputs and begin serial
void setup() {
pinMode(statusLed,OUTPUT); // declare the LED's pin as output
Serial.begin(31250); //start serial with midi baudrate 31250 or 38400 for debugging
digitalWrite(statusLed,LOW);
}
void loop () {
if (Serial.available() > 0) {
incomingByte = Serial.read();
// wait for as status-byte, channel 1, note on or off
if (incomingByte==144){ // 144 is note on ch1
digitalWrite(statusLed, HIGH);
delay(20);
digitalWrite(statusLed, LOW);
delay(1);
}
}
}
For Hardware, I have a arduino diecimila and an optoisolated midi in like this:http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1187962258/all Im using midi out from a microkorg keyboard, on channel 1.
The most frustrating thing is it worked once, briefly, and after many failed attempts. (Out of frustration, and lack of other ideas) I took the lead from the opto out (pin 5) and touched it directly to the ATMEGA pin 2 ( rx). I also accidently touched pin 1 and found that I can trigger the board to reset with each keystroke.
Directly touch the pin didnt work but when I pit the lead back into the RX socket, it worked. I was amazed, but when I unhooked the lead and put it back again, no dice. My first thought was that it was a loose or bad connection, but after an exhaustive search I have found nothing. I get a very strong beep when i perform a continuity test between the opto pin 5 and the ATMega pin 2. Naturally, I tried touching the lead diectly to pin 2 many times. This does nothing and leads me to suspect that there is a problem with the ATMega and /or some software problem (I dont think that it is the sketch, though) Anyone have any ideas? I am using Arduino 018. But my arduino is from '07. VCould it be a bug or problem with the bootloader....Im just guessing.
When I had it working before it almost seemed like I had "jumpstarted" the arduino into reading the data. ?? does this make sense? What could cause the rx to not respond?
I dont have any "real" test equipment, but my Meter reads a steady 5.14v on the RX pin. Should this always be high? Im a noob with digital and programming pics, but shouldnt this be low to recieve input? (The midi input lead read about the same but flickers slightly with key action.)
I tried a simple skech to take a digital read of pin 0 and report back with serial.println. Unconnected it reads "I" and with a lead to ground I get "0", so it seems like it can read something.
I have no idea what to try next except to drop some cash on a new arduino and/or bootloaded chip and wait a week til they get here.
please, any ideas or suggestions are greatly appreciated.
thanks