Shop OBEX P1 Docs P2 Docs Learn Events
switch question — Parallax Forums

switch question

ryan4385ryan4385 Posts: 17
edited 2010-04-16 19:48 in BASIC Stamp
Is there a way to have a pushbutton switch to latch an output that can be unlatch by the stamp

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-03-25 04:02
    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.
  • ryan4385ryan4385 Posts: 17
    edited 2010-03-25 05:40
    will any flipflop work or does it have to be a certain one and can you give example of the second idea
  • ryan4385ryan4385 Posts: 17
    edited 2010-03-25 22:28
    how would the flip-flop be wire up
  • Mike GreenMike Green Posts: 23,101
    edited 2010-03-25 22:57
    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
    Tutorial: www.parallax.com/tabid/535/Default.aspx

    Post Edited (Mike Green) : 3/25/2010 11:08:24 PM GMT
  • ryan4385ryan4385 Posts: 17
    edited 2010-04-09 05:22
    hey can write a very basic program so i can know how to control the flip-flop
  • Scott4Scott4 Posts: 45
    edited 2010-04-09 13:56
    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
    1114 x 337 - 12K
  • ryan4385ryan4385 Posts: 17
    edited 2010-04-10 02:17
    can anyone write the program for bs2 for the basic operation of the flipflop
  • FranklinFranklin Posts: 4,747
    edited 2010-04-10 03:45
    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

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • ryan4385ryan4385 Posts: 17
    edited 2010-04-16 14:06
    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
  • ercoerco Posts: 20,256
    edited 2010-04-16 19:48
    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."
Sign In or Register to comment.