Shop OBEX P1 Docs P2 Docs Learn Events
Is it possable to make a flip flop program? — Parallax Forums

Is it possable to make a flip flop program?

PrettybirdPrettybird Posts: 269
edited 2009-06-16 15:42 in Robotics
· Getting creative with my first bot. I have several·2 on,off channels on a parallax R/C controller board. I would like to use one as a program stop and start to control a·disable enable·for a roaming with ping. The Boe book says nothing of this. I am a newbee and know what can be done with software but not a programmer. Any ideas would be appreciatted. I like this room alot.

The more you learn, the more you find you don't know. It is neverenging. Confucous· 550 BC

Comments

  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2009-06-16 15:42
    Prettybird,

    To implement a switch toggle look at the section in the BOE that goes over switches (The Whisker section)...

    page 182 on the Roboticsv2_2.pdf

    ... only instead of whiskers you use a switch. To Toggle, or "Flip-Flop", when you detect a switch closure in your program you can do something like...

    PSEUDO Code Example:
    If ButtonSwitch = 0 then
       ToggleSwitch = 1 - ToggleSwitch    ' This line is your Flip Flop
       PAUSE 250                          ' Pause for 1/4 second - helps with switch debouncing
    
    


    ...In the rest of your program, you look to see what the state of ToggleSwitch is. If it's a "1" then run your program as usual, if it's a "0" SLEEP, and monitor the switch periodically.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
Sign In or Register to comment.