Pages: [1]   Go Down
Author Topic: how to send once then stop sending?  (Read 822 times)
0 Members and 1 Guest are viewing this topic.
California. USA
Offline Offline
Full Member
***
Karma: 0
Posts: 130
my guitar wants to kill your mama
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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?
Logged

UK
Offline Offline
Faraday Member
**
Karma: 17
Posts: 2884
Gorm deficient
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Send it in "setup", or set a flag to say "I've-sent-it-so-don't-send-it-again"
« Last Edit: March 10, 2010, 03:21:51 am by GrooveFlotilla » Logged

Per Arduino ad Astra

California. USA
Offline Offline
Full Member
***
Karma: 0
Posts: 130
my guitar wants to kill your mama
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

UK
Offline Offline
Faraday Member
**
Karma: 17
Posts: 2884
Gorm deficient
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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"
Logged

Per Arduino ad Astra

California. USA
Offline Offline
Full Member
***
Karma: 0
Posts: 130
my guitar wants to kill your mama
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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....
Logged

UK
Offline Offline
Faraday Member
**
Karma: 17
Posts: 2884
Gorm deficient
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So only send the message when the value changes
Logged

Per Arduino ad Astra

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 94
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You could use the following:
Code:
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.
Logged

UK
Offline Offline
Faraday Member
**
Karma: 17
Posts: 2884
Gorm deficient
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
touchX <> touchXOld

BASIC alert!

"!="
Logged

Per Arduino ad Astra

Pages: [1]   Go Up
Jump to: