View Full Version : switch question
03-25-2010, 10:43 AM
Is there a way to have a pushbutton switch to latch an output that can be unlatch by the stamp
03-25-2010, 11:02 AM
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.
03-25-2010, 12:40 PM
will any flipflop work or does it have to be a certain one and can you give example of the second idea
03-26-2010, 05:28 AM
how would the flip-flop be wire up
03-26-2010, 05:57 AM
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.
Datasheet: www.nxp.com/documents/data_sheet/74HC_HCT74.pdf (http://www.nxp.com/documents/data_sheet/74HC_HCT74.pdf)
Tutorial: www.parallax.com/tabid/535/Default.aspx (http://www.parallax.com/tabid/535/Default.aspx)
Post Edited (Mike Green) : 3/25/2010 11:08:24 PM GMT
04-09-2010, 12:22 PM
hey can write a very basic program so i can know how to control the flip-flop
04-09-2010, 08:56 PM
Hi Ryan, here is a circuit I use to toggle a line that goes to a voltage regulator to turn power on and off. -Scott
04-10-2010, 09:17 AM
can anyone write the program for bs2 for the basic operation of the flipflop
04-10-2010, 10:45 AM
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
04-16-2010, 09:06 PM
Mr mike green,
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
·"If you build it, they will come."