Shop OBEX P1 Docs P2 Docs Learn Events
Beginner need help with programing SX/B — Parallax Forums

Beginner need help with programing SX/B

ProjsxProjsx Posts: 4
edited 2005-02-05 16:08 in General Discussion
I am a beginner in the programing enviorment and very much interested in the SX/B

I need assistance to write SX basic code to allow a TTL button to have the following function

Press once = 1 then hold till ·Press again = 0 then hold till. ·repeat the process. This function will be similar to a flip flop ckt.

Tks.

Comments

  • BeanBean Posts: 8,129
    edited 2005-01-13 22:42
    Do you want the "1" and "0" to be a different pin or just a variable that gets set ?
    How do you have the button connected ?

    Bean.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-01-13 23:34
    I think you could do that fairly simply:

    status··· VAR··· Bit

    Main:
    · IF RA.0 = 0 THEN Main
    · status = status XOR 1
    · PAUSE 50
    · GOTO Main

    Note that this is a partial listing just to show you the guts of your request.· The PAUSE is inserted to debounce the button a bit.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • ProjsxProjsx Posts: 4
    edited 2005-01-22 14:22
    Thanks for the advice but I am still having problem with this project. Still need your assistance.

    Below is an explanation of the project.
    This project consist of two buttons Button A and Button B

    Press button A once to turn a light ON, Press button A again to turn a light OFF
    Input button RB4 ( TTL +5v/0v)
    Output RB5 driving the base of a transistor which in turn control a relay that turn a light ON or OFF

    Press button B once to turn a motor ON, Press button B again turn a motor OFF
    Input button RB5 ( TTL+5v/0v)
    Output RB6 driving the base of a transistor which in turn control a relay that turn a motor ON of OFF

    Tks Projsx
  • ProjsxProjsx Posts: 4
    edited 2005-01-22 14:26
    Correction typo

    Buton B input RB6
    Output RB7
    Tks.
    Projsx
  • BeanBean Posts: 8,129
    edited 2005-01-22 15:57
    · IF RB.4 = 1 THEN Button1Up
    · TOGGLE RB.5
    · PAUSE 50
    Button1Down:
    · IF RB.4 = 0 THEN Button1Down
    Button1Up:
    · IF RB.6 = 1 THEN Button2Up
    · TOGGLE RB.7
    · PAUSE 50
    Button2Down:
    · IF RB.6 = 0 THEN Button2Down
    Button2Up:

    Bean.
  • ProjsxProjsx Posts: 4
    edited 2005-02-05 16:08
    Thank you very much for the support.
    The program is now working great.
    Can't wait to start another program with SXB.

    Thanks again.

    Projsx
Sign In or Register to comment.