Getting "BUTTON" to work
ghost13
Posts: 133
My BS1 system should beep once at startup and then wait until a button is pressed. Then, it should continuously beep.
Right now, with the below code, the piezo just turns on (the switch is off - it should only turn on when the switch if first turned on):
I also tried changing this line:
to this line:
The result is the same [noparse]:([/noparse]
Help would be appreciated!!! Thanks!!
Right now, with the below code, the piezo just turns on (the switch is off - it should only turn on when the switch if first turned on):
Main: HIGH 3 PAUSE 250 LOW 3 goin = 0 GOTO Try Try: FOR reps = 1 TO 0 HIGH CS ' Deactivate the ADC to begin. GOSUB Convert grnd = AD*1 GOSUB Convert ' Get data from ADC. prev= AD BUTTON Btn, 4, 200, 20, btnWrk, 1, Again NEXT Again: HIGH 3
I also tried changing this line:
BUTTON Btn, 4, 200, 20, btnWrk, 1, Again
to this line:
BUTTON Btn, 4, 200, 20, btnWrk, 0, Again
The result is the same [noparse]:([/noparse]
Help would be appreciated!!! Thanks!!
Comments
FOR reps = 1 TO 0? Where is your Convert subroutine? It seems there is code missing...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Is this wrong?
Should I just call GOTO Try instead?
Thanks!
It may be in infinte loop in some variants of BASIC, but not in PBASIC. Take a look at the LOOP command, or use the GOTO as you suggested.
Regards,
Bruce Bates
I want it to only activate one time when the button is first pressed, and then not concern itself with the button again.
Here's the code:
What's wrong?
Thanks!
Until you can post the completed code I doubt you’re going to get any better answers. I don’t even see how that code could compile since your Convert subroutine is missing and the code seems to END at the HIGH 3 command.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
So... is my BUTTON code correct? I want it to execute Again, which calls itself forever (until apogee is reached). Once button executes once, it should be ignored.
Thanks!
Post Edited (ghost13) : 6/13/2007 6:06:08 AM GMT
Thanks!
Here is the full code:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support