problem with else command


hi guys,
so have been trying last problem sorted out last few days no luck.
i trying else command send midi message 1 time regardless of changes in "touchx".

here section of sketch stuck on:
code: [select]
if(touchx > 127 && touchx != touchxold)
{
 touchxold = touchx;
 midi.sendcontrolchange(92,0,1);
} else
[glow]  if(touchx < 127  && touchx != touchxold)
{
 touchxold = touchx;
 midi.sendcontrolchange(92,127,1);[/glow]
}
it reads values of resistive touch screen, value of "touchx" comes from.
basically need above highlighted part send midi message 1 time being resent every time there change in "touchx".
i have tried can think of.

is touchx stable? how move around? under circumstances?

if keep touching screen, not moving, touchx remain constant, or vary slightly?

what happen when touchx equal 127? have if test might true when touchx greater 127, , 1 might true when less 127, nothing when equal 127.

what rest of code like? code, you'd need introduce variable keep track of whether necessary send midi message 127 in it.

finally, seem you'd want send stop message (once) whenever motion stopped (touchx == touchxold), not when stopped , value of touchx small.


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > problem with else command


arduino

Comments