Send a Serial.write only once

HI i have this Midi cc sender, and it works XD But, but ,but. Nothing is at easy as it seems..

Well im using Arduino IDE 0023 to make the byte command to work. ( so please nevermind the BYTE command ) My problem is that my midi buffer gets full within a secounds because whtn my input bottonPin(2) is off, it is sending that Off signal all the time!

so i need my Buddy "arduino" just to send the "OFF" signal Once and then send nothing before i get a "ON or HIGH" input

Here is my skech so far

int buttonPin2 = 2; byte val2H = 127; // Input 2 HIGH value MIDI byte val2L = 0; // Input 2 LOW value MIDI int val2Input; // Input 2 HIGH / LOW

void setup() { Serial.begin(31250); // MIDI BAUD RATE pinMode(buttonPin2, INPUT);

}

void loop() {

val2Input = digitalRead(2); // if (val2Input == HIGH) { Serial.print(0xB0, BYTE); // MIDI control change; channel 1 Serial.print(2, BYTE); // MIDI controller #1 CC#2 Serial.print(val2H, BYTE); // MIDI controller value 2 } if (val2Input == LOW) { Serial.print(0xB0, BYTE); // MIDI control change; channel 1 Serial.print(2, BYTE); // MIDI controller #1 CC#2 Serial.print(val2L, BYTE); // MIDI controller value 2

} } }

Send the signal only when the state of the input changes, not all the time it is in one state or the other.

OK, ive tryed to write something in the "state" mind, but i could not get it to work :~ Any suggestions, the examples has a counter in it, but i have no interest in the counter function..

OK, ive tryed to write something in the "state" mind, but i could not get it to work

But you didn't post it.