Using a switch with the SEROUT command
TonyA
Posts: 226
Hi,
I am wondering if anyone could help me with some code. I would like to use a switch with the serout command like
Switch = On THEN
SEROUT something
However, I would like to only have the SEROUT event occur once if the switch remains in the ON position. So in other words I can only produce another SEROUT event if the switch is switched back to the off position and then back to the on position.
The SEROUT event in my application is for sending MIDI notes. So I am trying to have a switch (the piezo Vibra Tab) only produce one note when pressed, if pressure applied to the piezo is held it will only produce that one note until pressure is released and than reapplied. Like a midi drum pad.
Thanks for any help with this.
Tony A.
I am wondering if anyone could help me with some code. I would like to use a switch with the serout command like
Switch = On THEN
SEROUT something
However, I would like to only have the SEROUT event occur once if the switch remains in the ON position. So in other words I can only produce another SEROUT event if the switch is switched back to the off position and then back to the on position.
The SEROUT event in my application is for sending MIDI notes. So I am trying to have a switch (the piezo Vibra Tab) only produce one note when pressed, if pressure applied to the piezo is held it will only produce that one note until pressure is released and than reapplied. Like a midi drum pad.
Thanks for any help with this.
Tony A.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Thanks for that code. I'll have to figure this out. I'm not sure yet how to apply it to what I'm doing. (Sometimes these things take longer to sink in these days).
I was wondering though, if there might be another way to do this.
Suppose I had a simple on/off switch. If the switch is turned on only one midi note (one SEROUT event) would be produced, then stop even though the switch is still in the on position. Another (2nd) SEROUT event could only be produced if the switch is turned off and then on again. Is there a way to do this with the SEROUT command instead of monitoring the state of the switch?
Thanks again, I appreciate it.
Tony A.
Brute_Force:
· DO : LOOP WHILE (TheButton = Pressed)·········· ·' force release
· DO : LOOP UNTIL (TheButton = Pressed)·········· ·' wait for clean 0 -> 1 press
· SEROUT Sio, Baud, [noparse][[/noparse]NoteOn, theNote, velocity]
· DO : LOOP WHILE (TheButton = Pressed)········· · ' force release
· DO : LOOP UNTIL (TheButton = Pressed)·········· ·' wait for clean 0 -> 1 press
· SEROUT Sio, Baud, [noparse][[/noparse]NoteOff, theNote, velocity]
· GOTO Brute_Force
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 2/26/2006 7:43:59 PM GMT
I'm starting to understand now. You need the condition of "off plus on" to trigger.
Is that what this is doing?
IF (xBtns.LOWBIT(idx) = 1) THEN
Thanks,
Tony
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
I was wondering about a couple of lines in the code you posted above. In the MAIN section there is "FOR idx = 0 TO 3" for the 4 input pins. In the "Get_Buttons" (sub routine) section I see "FOR idx = 1 TO 5" <--- I'm just wondering what that is for.
Thanks again,
Tony A
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
I am looking up Stamp Works Exp 14, I see Exp 15 but without the switch state detection code in it, only Debounce. Is there an explaination of the code for Debounce plus Switch state detection?
Tony A
Post Edited (TonyA) : 2/27/2006 2:10:41 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Tony A