Go Down

Topic: how to send once then stop sending? (Read 973 times) previous topic - next topic

spookybonus

I can not figure out how to get this CC message to just send one time.
The message is continuously being sent out as either a 0 or 127.

This is the code i am working with.
Code: [Select]
if(touchX > 127)
{MIDI.sendControlChange(22,0,1);   //needs to be sent only once
}
else
{
MIDI.sendControlChange(22,127,1);   //needs to be sent only once
}


isn't there some way to say "just send once" or something to that effect?

Groove

#1
Mar 10, 2010, 09:21 am Last Edit: Mar 10, 2010, 09:21 am by GrooveFlotilla Reason: 1
Send it in "setup", or set a flag to say "I've-sent-it-so-don't-send-it-again"
Per Arduino ad Astra

spookybonus

i actually need it to happen over and over (each time the "touchX" value triggers it)

i tried the setup method and that didnt work out.


Groove

Quote
i actually need it to happen over and over


So why did you ask for a method to send it only once?

Quote
isn't there some way to say "just send once"
Per Arduino ad Astra

spookybonus

because i want it to send the message one time per trigger.

when the value is triggered as it is it sends out the message constantly slamming my midi device with non-stop messages, rather than just the one message to turn the function on.

basically i want it to operate as if it were a button sending an on then off message.
not like: on on on on on on on on on on on on on on on on off off off off off off off off off off off off off off off off off off off off off off....

Groove

So only send the message when the value changes
Per Arduino ad Astra

programmer

You could use the following:
Code: [Select]
touchXOld = 0
if(touchX > 127 && touchX <> touchXOld){
 touchXOld = touchX;
 MIDI.sendControlChange(22,0,1);   //needs to be sent only once
} else {
 MIDI.sendControlChange(22,127,1);   //needs to be sent only once
}  


Which triggers when touchX is greater than 127, and then again only when touchX is greater than 127 and different to the previous value.

Groove

Code: [Select]
touchX <> touchXOld

BASIC alert!

"!="
Per Arduino ad Astra

Go Up