BUTTON Command
ngilliam
Posts: 2
This is a school project and am limited to what hardware I can use. This project is to test our ability to build a circuit, not test our programming abilities. The TAs are more than willing to help our programming but have been overrun by questions so I thought I would post here and see if I could get a quicker response.
I have a program that runs an LED matrix. I have added 3 buttons, one to change the pattern, one to change the speed, and one to turn it on or off. I gave each button a subroutine and was using GOSUB between each light to check the state of the buttons and act accordingly. I think it works (my hardware won't come in until Monday to do any testing), but the problem is, my program is huge so I knew there had to be a better way. Searching here I found the BUTTON command. I read the Basic Stamp Manual about BUTTON but have a question.
If I press a button, does it automatically run the BUTTON command even if it is in the middle of a different routine? Is there a better command to use? In the case of my speed button, is there any way to get it to pick up where it left off?
Thanks in advance.
I have a program that runs an LED matrix. I have added 3 buttons, one to change the pattern, one to change the speed, and one to turn it on or off. I gave each button a subroutine and was using GOSUB between each light to check the state of the buttons and act accordingly. I think it works (my hardware won't come in until Monday to do any testing), but the problem is, my program is huge so I knew there had to be a better way. Searching here I found the BUTTON command. I read the Basic Stamp Manual about BUTTON but have a question.
If I press a button, does it automatically run the BUTTON command even if it is in the middle of a different routine? Is there a better command to use? In the case of my speed button, is there any way to get it to pick up where it left off?
Thanks in advance.
Comments
If you want more help with your question, you really have to post your program for us to look at. Use the "+Reply to Thread" button, but click on the "Go Advanced" button. This will bring up a more complex window that includes an Attachment Manager that will let you upload your source program as an attachment to your message. DO NOT use cut and paste to put your program into your message. That actually makes it hard to read and annoys people unless the program is really short.
First study how to use pushbuttons with the Stamp. Chapter 2 of "What's a Microcontroller?" discusses how to use LEDs with a Stamp. Chapter 3 discusses how to use pushbuttons including how to control LEDs with pushbuttons and a Stamp. Once you have that under control, come back with a description of how you want your Stamp program to behave ... what you want the pushbuttons to do and describe the LED patterns