You can use a flipflop with the pushbutton triggering the set input to the flipflop and the Stamp triggering the reset input. You can also have the Stamp watch the switch and, when it's pressed, set one of its output bits (I/O pins) to 1, then the Stamp can reset the output to 0 under whatever conditions you define.
The 74HC74 is a typical dual flipflop. You'd connect one flipflop as follows:
SD to a switch wired up as shown on page 79 of What's a Microcontroller?
D to Vss (ground)
CP to Vss (ground)
RD to another Stamp I/O pin (different from the one used for the pushbutton)
Q is the flipflop output pin. The Stamp program can read the pushbutton switch setting as shown in Chapter 3 of What's a Microcontroller? The I/O pin connected to RD should be initialized to HIGH. When it's made LOW, the flipflop will reset and stay that way until this pin is made HIGH again.
ryan4385, "Is there a way to have a pushbutton switch to latch an output that can be unlatch by the stamp"
If you have a button on pin 3 you could do something like \
If IN3 THEN HIGH 5
...
...
...
...
LOW 5
U said by using the a flipflop i can do but i cant seem to figure out the program part. if you could real quickly write a program to control the flipflop it would be greatly appreciate?
Ryan: Everyone here is quite happy to help! Run this short program, I guarantee it will get the results you seek:
itdoesntwork VAR BIT
trytryagain: pause 1000
DEBUG "We're here to help, but not do your Stamp homework for you."
DEBUG "You must make some effort to learn programming."
DEBUG "Stamp programming is actually fun. Write some code and try it out!"
IF itdoesntwork=1 THEN trytryagain ELSE comebackforhelp
comebackforhelp: DEBUG "Post your code in the forum and ask for assistance",CR
end
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ ·"If you build it, they will come."
Comments
SD to a switch wired up as shown on page 79 of What's a Microcontroller?
D to Vss (ground)
CP to Vss (ground)
RD to another Stamp I/O pin (different from the one used for the pushbutton)
Q is the flipflop output pin. The Stamp program can read the pushbutton switch setting as shown in Chapter 3 of What's a Microcontroller? The I/O pin connected to RD should be initialized to HIGH. When it's made LOW, the flipflop will reset and stay that way until this pin is made HIGH again.
Datasheet: www.nxp.com/documents/data_sheet/74HC_HCT74.pdf
Tutorial: www.parallax.com/tabid/535/Default.aspx
Post Edited (Mike Green) : 3/25/2010 11:08:24 PM GMT
If you have a button on pin 3 you could do something like \
If IN3 THEN HIGH 5
...
...
...
...
LOW 5
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
U said by using the a flipflop i can do but i cant seem to figure out the program part. if you could real quickly write a program to control the flipflop it would be greatly appreciate?
Ryan
itdoesntwork VAR BIT
trytryagain: pause 1000
DEBUG "We're here to help, but not do your Stamp homework for you."
DEBUG "You must make some effort to learn programming."
DEBUG "Stamp programming is actually fun. Write some code and try it out!"
IF itdoesntwork=1 THEN trytryagain ELSE comebackforhelp
comebackforhelp: DEBUG "Post your code in the forum and ask for assistance",CR
end
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."