Push-button help in BS2..
Hello all·Engineers and Engineer-to-be..·
·
·
It is me again!
I really appreciate your help for the EB-500, the project am doing is working fine!
·
This time I want to ask about the push-button. I want to use it for the same project I am working on.
My question is, how can I make an LED high for 10 seconds after pressing a push-button once? ·
What I know is that when I press it a 5V is passing through and make the LED on while holding it, and when I release it the LED is off.
·
Thank you again for the help!
·
Regards,
Future_Engineer!
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
~Swimming in·the ocean·of Electronic Engineering~
Post Edited (Future_Engineer) : 4/15/2008 8:04:13 PM GMT

·
It is me again!
I really appreciate your help for the EB-500, the project am doing is working fine!
·
This time I want to ask about the push-button. I want to use it for the same project I am working on.
My question is, how can I make an LED high for 10 seconds after pressing a push-button once? ·

What I know is that when I press it a 5V is passing through and make the LED on while holding it, and when I release it the LED is off.
·
Thank you again for the help!
·
Regards,
Future_Engineer!
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
~Swimming in·the ocean·of Electronic Engineering~
Post Edited (Future_Engineer) : 4/15/2008 8:04:13 PM GMT
Comments
Actually I didn't wrote the program for the push-button yet, I mean I was reading the manual to find out what I want and I read that the push-button will make the LED high when it is pressed only! So, I said that I might find the answer here!
I'll try to write the program "but am not sure if it will be correct since my head is programmed with the Visual Basic codes now! I am using it for the project also"..
Thank you!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
~Swimming in·the ocean·of Electronic Engineering~
Post Edited (Future_Engineer) : 4/15/2008 8:04:31 PM GMT
I've done the flow chart for·the push-button test, and I still haven't wrote the program since I am·working on the Visual Studio also!
I think I have some problems with the IF command, I am not sure how to write (If push-button pressed once) as a code!
I hope someone will be able to help!
Thank you!
PS: I am planning to use Pin 5 for the push-button, Pin 11 for Green LED and Pin 12 for Red LED!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
~Swimming in·the ocean·of Electronic Engineering~
instead of drawing flowcharts using ms word -- which is a waste of time and memory -- try something simpler and more
straight forward, like:
This is probably not the best solution to your problem, but it is easy to implement and close to what you
suggested with your flow chart. Disadvantages of this solution are that the stamp does a lot of busy waiting
reading the button and keeping the LED on, but this shall be kindly ignored here.
A bit of comment: you don't need the PUSHBUTTON command for your solution, it is unnecessarily complex and
can be replaced by merely reading a single bit input (0 button released, 1 button pressed).
Regards
Adrian
And thanks for everyone who tried to help!
I have figured out what I want, if you are interested here is the program that I've wrote:
'{$STAMP BS2}
BtnWrk VAR Byte
Wait_Button:
BUTTON 5,1,255,0,BtnWrk,0,Wait_Button
HIGH 11
PAUSE 2500
LOW 11
HIGH 12
PAUSE 2500
LOW 12
GOTO Wait_Button
Thanks again!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
~Swimming in·the ocean·of Electronic Engineering~
I have a question again!
Is it possible to use the IF command with the BUTTON?? If yes, how?
Thanks!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
~Swimming in·the ocean·of Electronic Engineering~
I mean, IF this
(Wait_Button:
BUTTON 5,1,255,0,BtnWrk,0,Wait_Button)
THEN this
(HIGH 11
PAUSE 2500
LOW 11
HIGH 12
PAUSE 2500
LOW 12
END)
or do this
(HIGH 13
PAUSE 2500
END)
I hope its clear, and sorry for my bad explanation!
It is just a question, because when I wrote that BUTTON program it was working, but when I put it with my other program (as a part of it) it was not working!
Sorry for asking so much. I do because it is my 1st time using the BASIC Stamp and it is a part of my senior project!
I am happy to work with it because it is much easier than other Microcontrollers programming!
Thank you again for your help!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
~Swimming in·the ocean·of Electronic Engineering~
The BUTTON statement, as written, waits for a pushbutton to be pressed. You have two paths out of the BUTTON statement, one path is the case where the button is not pressed, the other path is the case where the button is pressed. The first causes a GOTO to Wait_Button, the second "falls through".
Are those the two cases where you want different things to happen?
I was wondering about that also!
Can you please tell me what exactly this means?
(5,1,255,0,BtnWrk,0,Wait_Button)
I have read the manual but didn't understand it all! Maybe I have to change something there to make the push-button work on my project!
Thank you again for your help!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
~Swimming in·the ocean·of Electronic Engineering~
The manual really does give a good explanation of the different parameters. Here's an overview:
Pushbuttons "bounce" when pressed and when released. The contacts literally bounce against each other causing an intermittent connection for a period of time. The BUTTON statement does several things. It "debounces" the switch closure. In other words, once it detects that the switch is closed, it checks periodically that the switch is still closed and doesn't report that the switch is closed until it has been closed consistently for a period of time. The BUTTON statement can also optionally simulate multiple button presses if the pushbutton is pressed and held for a period of time. This is like repeating keys on a keyboard. Both the debouncing and the repeating are things that happen over a period of time, so the BUTTON statement has to be executed over time, so it has to be in some kind of loop. The work area (BtnWrk) is a variable where the interpreter stores the current state of the debouncing and repeat processes. The label (Wait_Button) is one path out of the statement (the other is to "fall through"). This label can be used to repeat the BUTTON statement if the button isn't pressed or to branch to somewhere if the button is pressed. Your choice. Think of this statement as a complicated version of "IF button pressed THEN" or "IF button not pressed THEN" that takes care of debouncing for you if you repeatedly execute it.
In your case, "5" is the I/O pin used. "1" is the value (state) assigned for when the button is pressed. "255" indicates that debouncing is to be done, but no automatic repeating is done. "0" is the number of times BUTTON has to be executed for each auto-repeat (ignored in this case). "Btn_Work" is the work area name. "0" is the state for the branch to be taken (IF buttonState = thisState THEN GOTO xxx). "Wait_Button" is the label for the branch.
Typically, in a program, you'd have two loops. The first would wait (using BUTTON) until the button is pressed, then your program would do something, then you'd wait (using BUTTON) until the button is released, then go back to the first loop.
Post Edited (Mike Green) : 4/19/2008 2:44:22 PM GMT
Actually, I want to use the push-button in my project as an emergency exit switch. I mean, in my project I am using the EB-500 to do what I've programed to do, and I want to use the push-button in this case to do exactly what the EB-500 will do if I press it once as an emergency switch if the EB-500 is not working!
That progrm above is actually doing what I want it to do, and it works fine when I test it! But somehow when I combine my EB-500 program with that program, the push-button is not working!
Is there any ideas?
P.S: Forgive me for asking so much! And I really appreciate your understanding!
Thank you again Sir!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
~Swimming in·the ocean·of Electronic Engineering~
Thank you so much for your help! If I couldn't solve it, I'll send you a PM with more details about the EB-500 program (since it is my senior project and no one should know the details till I officially finish it and my Prof.s grade it)!
Thank you for understanding Sir!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
~Swimming in·the ocean·of Electronic Engineering~
I have another question. How can I use the Serial Time-Out Feature withe the push-button?
Actually I didn't understand the timeout feature when I read the manual!
I hope I can find the answer for my question soon!
Thanks a lot!
Regards,
Future_Engineer
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
~Swimming in·the ocean·of Electronic Engineering~
Here is a block of code from my "Timeset" code segment (Slot 1) that does what you are asking about.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
~Swimming in·the ocean·of Electronic Engineering~