I was writing the sketch by kuk, step by step, to verify that every line works well, without errors.
Till i found one: playNote(note,0);
As playNote was not declared un the scope. Besides, i don't know where to place it.
//variables setup
byte incomingByte;
byte note;
byte velocity;
int statusLed = 13; // select the pin for the LED
int action=2; //0 =note off ; 1=note on ; 2= nada
//setup: declaring iputs and outputs and begin serial
void setup() {
pinMode(statusLed,OUTPUT); // declare the LED's pin as output
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
//start serial with midi baudrate 31250 or 38400 for debugging
Serial.begin(31250);
digitalWrite(statusLed,HIGH);
}
//loop: wait for serial data, and interpret the message
void loop () {
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
// wait for as status-byte, channel 1, note on or off
if (incomingByte== 144){ // note on message starting starting
action=1;
}else if (incomingByte== 128){ // note off message starting
action=0;
}else if (incomingByte== 208){ // aftertouch message starting
//not implemented yet
}else if (incomingByte== 160){ // polypressure message starting
//not implemented yet
}else if ( (action==0)&&(note==0) ){ // if we received a "note off", we wait for which note (databyte)
note=incomingByte;
playNote(note, 0);
note=0;
velocity=0;
action=2;
}
Well, you can see that in the last ElseIf statement, playNote appears, but it was not declared anywhere in the program. I try to place it in the variables setup, but did not work. Nor as an int function.
If you read the thread you just quoted you should find the code you seem to have taken out where playNote() is defined. Putting that back in might help.
Well , i was writing the program step by step. Checking every paragraph, before adding a new one. So to not make mistakes...Till i added the playnote function... and the program said this function was not declared in the scope... :o
Dl8k:
Well , i was writing the program step by step.
That is a good way to develop your own program but it does not make sense to do it for an existing program because you need all the components of the existing program.
Well, finally it works!. I thougt i could write the sketch step by step to avoid errors, but not always is a good idea. : Besides, i commited some syntax mistakes... So please accept my excuses.
Anyway, the sketch is correct. Another matter will be the test: i have an old Roland synthesizer...the first to feature midi ports, that only transmits/responds to fixed velocity (64). The optocouplers i will use are 6n137/139. I will try if it works...