Checking multiple inputs
Oper8r Al
Posts: 98
I have Quadravox sound module set up so I can tigger sounds with a four button remote. There are also two toggle switches to select between four different themes. I am still learning and was using some things I had available. I'm sure this isn't the best way to·program it but I was just happy I got it to work. ·Here is the Code I am using to check the remote buttons:
·Check_RemBtns:
·· IF IN15=1 THEN
··· LOOKUP sound, [noparse][[/noparse]remBtnA], phrase
·· GOSUB Say_Phrase
··· DEBUG "Remote Button A.",CR
··· DO : LOOP WHILE (QV_Busy = IsBusy)
·· ELSEIF IN14=1 THEN
··· LOOKUP sound, [noparse][[/noparse]remBtnD], phrase
·· GOSUB Say_Phrase
··· DEBUG "Remote Button D.",CR
··· DO : LOOP WHILE (QV_Busy = IsBusy)
·· ELSEIF IN13=1 THEN
··· LOOKUP sound, [noparse][[/noparse]remBtnC], phrase
·· GOSUB Say_Phrase
··· DEBUG "Remote Button C.",CR
··· DO : LOOP WHILE (QV_Busy = IsBusy)
·· ELSEIF IN12=1 THEN
··· LOOKUP sound, [noparse][[/noparse]remBtnB], phrase
·· GOSUB Say_Phrase
··· DEBUG "Remote Button B.",CR
··· DO : LOOP WHILE (QV_Busy = IsBusy)
·· ENDIF
· RETURN
I plan on removing the debug lines. I had them there so I could see if the buttons were being read. I was wondering how I could use something like Jon Williams had suggested in this post. http://forums.parallax.com/showthread.php?p=558282
I know I would have to change it so it reads IN12-15 instead of IN0-3, but I'm not clear on how I can get the program to· trigger the sounds when the buttons are pressed.
I hope this makes sense. If it helps I can post the whole program.
Thanks
Alan
·Check_RemBtns:
·· IF IN15=1 THEN
··· LOOKUP sound, [noparse][[/noparse]remBtnA], phrase
·· GOSUB Say_Phrase
··· DEBUG "Remote Button A.",CR
··· DO : LOOP WHILE (QV_Busy = IsBusy)
·· ELSEIF IN14=1 THEN
··· LOOKUP sound, [noparse][[/noparse]remBtnD], phrase
·· GOSUB Say_Phrase
··· DEBUG "Remote Button D.",CR
··· DO : LOOP WHILE (QV_Busy = IsBusy)
·· ELSEIF IN13=1 THEN
··· LOOKUP sound, [noparse][[/noparse]remBtnC], phrase
·· GOSUB Say_Phrase
··· DEBUG "Remote Button C.",CR
··· DO : LOOP WHILE (QV_Busy = IsBusy)
·· ELSEIF IN12=1 THEN
··· LOOKUP sound, [noparse][[/noparse]remBtnB], phrase
·· GOSUB Say_Phrase
··· DEBUG "Remote Button B.",CR
··· DO : LOOP WHILE (QV_Busy = IsBusy)
·· ENDIF
· RETURN
I plan on removing the debug lines. I had them there so I could see if the buttons were being read. I was wondering how I could use something like Jon Williams had suggested in this post. http://forums.parallax.com/showthread.php?p=558282
I know I would have to change it so it reads IN12-15 instead of IN0-3, but I'm not clear on how I can get the program to· trigger the sounds when the buttons are pressed.
I hope this makes sense. If it helps I can post the whole program.
Thanks
Alan
Comments
Check_RemBtns:
· DO
··· select = DCD IND
· LOOP UNTIL (select > 0)
· select = select - 1
· LOOKUP select, [noparse][[/noparse]RemBtnA, RemBtnB, RemBtnC, RemBtnD],·phrase
· GOSUB Say_Phrase
· DEBUG "Remote Button ", ("A" + select)
· DO : LOOP WHILE (QV_Busy = IsBusy)
· RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
··· Thanks for the help. I was just wondering where I could find more info on DCD (select = DCD IND). I have been tryingto use·the help files on the editor, the books I have and the d/ls available online to try and solve the problems I come across.·Sometimes I get·frustrated with myself and need a little help and I am thankful for the advice the parallax people and other forum members·provide.
Alan
ALL PBASIC Commands can be found both in the PBASIC Manual and also in the PBASIC Help File. The PBASIC Manual can be downloaded from here:
http://www.parallax.com/html_pages/downloads/basicstamps/documentation_basic_stamp.asp
Since the PBASIC Help File is part of the PBASIC Editor/Compiler, you can find it in that software download, available here (more options below):
http://www.parallax.com/html_pages/downloads/software/software_basic_stamp.asp
On that same web page mentioned above, you can also download JUST the PBASIC Help File. That is the third item in the list. The name of the file is "PBASIC.CHM" and it's a standared Windows Help File, thus, it can be executed independently of the PBASIC Editor/Compiler.
Regards,
Bruce Bates
Alan