Shop OBEX P1 Docs P2 Docs Learn Events
How do I set up a push button..? for sumo bot? — Parallax Forums

How do I set up a push button..? for sumo bot?

Kd7laxKd7lax Posts: 42
edited 2005-10-30 04:50 in BASIC Stamp
Hi,
well I finally got my sumo bots servo's connected, and I am going to do a presentation on microcontrollers for my (computer sci-100) class this monday... and I wanted to show off my mini-sumo-bot (home brewed version)... but I cant figure out how to hook up a pushbutton? what pins it should go to ect... also what code I should use for a 5sec delay ect. I think I just want it to do a little dance/demo ( because I won't have to sensors up and running by then).

So if some one could help me out that would be great!

thanks!
-Mike

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit my website @ www.kd7lax.com- Devoted to ham radio

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-10-28 14:39
    Hello,

    ·· You can find schematics on connecting a button to the SumoBot (Or any BASIC Stamp) in the Help File under the BUTTON command.· Now, I am not recommending the BUTTON command for your application, but the circuits apply to almost anything.· The code will be dependant on what you have and where in the code you want to read the buttons.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • dandreaedandreae Posts: 1,375
    edited 2005-10-28 16:07
    Also check out the "Whats' a Microcontroller" text, ·in chapter3 it shows you how to wire up a push button.· Here is a link for the download:
    · http://www.parallax.com/detail.asp?product_id=28152


    Dave

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dave Andreae

    Tech Support
    dandreae@parallax.com
    Http://www.parallax.com

    ·
  • Kd7laxKd7lax Posts: 42
    edited 2005-10-30 04:50
    ok I got the button all wired up, now I just need some code to run on it.... As far as I know ( I am new to this) I can make a button that once I download a program to the bs2 and have the power connected I press this button and 5 secondes later the program on the bs2 starts to run right?

    I want to run this moter testing code after Said button is pressed ( the button is hooked up to pin 9) .
    ' -----[noparse][[/noparse] Title ]----------------------------------------------------------------
    ' Mini Sumo 2.1 : Motor Test
    ' {$STAMP BS2}
    
    ' -----[noparse][[/noparse] I/O Definitions ]------------------------------------------------------
    
    LMotor          CON     13                      ' left servo motor
    RMotor          CON     12                      ' right servo motor
    
    ' -----[noparse][[/noparse] Constants ]------------------------------------------------------------
    
    LFwdFast        CON     1000                    ' left motor forward; fast
    LFwdSlow        CON      800                    ' left motor forward; slow
    LStop           CON      750                    ' left motor stop
    LRevSlow        CON      700                    ' left motor reverse; slow
    LRevFast        CON      500                    ' left motor reverse; fast
    
    RFwdFast        CON      500                    ' right motor forward; fast
    RFwdSlow        CON      700                    ' right motor forward; slow
    RStop           CON      750                    ' right motor stop
    RRevSlow        CON      800                    ' right motor reverse; slow
    RRevFast        CON     1000                    ' right motor reverse; fast
    
    ' -----[noparse][[/noparse] Variables ]------------------------------------------------------------
    
    pulses          VAR     Byte                    ' counter for motor control
    
    ' -----[noparse][[/noparse] Initialization ]-------------------------------------------------------
    
    Start_Delay:
      PAUSE 2000                                    ' time to disconnect cable
    
    ' -----[noparse][[/noparse] Main Code ]------------------------------------------------------------
    
    Main:
      FOR pulses = 1 TO 125                         ' forward slow - about 12 inches
        PULSOUT LMotor, LFwdSlow
        PULSOUT RMotor, RFwdSlow
        PAUSE 20
      NEXT
    
      FOR pulses = 1 TO 110                         ' pivot turn - left wheel (ccw)
        PULSOUT LMotor, LStop
        PULSOUT RMotor, RFwdSlow
        PAUSE 20
      NEXT
    
      FOR pulses = 1 TO 50                          ' forward fast
        PULSOUT LMotor, LFwdFast
        PULSOUT RMotor, RFwdFast
        PAUSE 20
      NEXT
    
      FOR pulses = 1 TO 30                          ' spin turn - clockwise
        PULSOUT LMotor, LFwdFast
        PULSOUT RMotor, RRevFast
        PAUSE 20
      NEXT
    
    Hold_Position:
      PULSOUT LMotor, LStop
      PULSOUT RMotor, RStop
      PAUSE 20
      GOTO Hold_Position
    


    Can some one help me make a code that will do this? or atleast get me started.

    thanks so much!
    -Mike

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Visit my website @ www.kd7lax.com- Devoted to ham radio
Sign In or Register to comment.