Shop OBEX P1 Docs P2 Docs Learn Events
count to determine boe bot action — Parallax Forums

count to determine boe bot action

hawkhunterhawkhunter Posts: 18
edited 2012-09-05 23:27 in BASIC Stamp
maybe this cant be done the way i want it to. or maybe it is the long way of doing it. but here goes.

I have done all the basic programs in the Robotics with the Boe-Bot book ver 3.0.

what i want to do is set the boe-bot up so that all the basic programs are all loaded verses having to carry my laptop with me to display the diff functions. The idea is to have a script at the beggening that will count how many times the tactical whisker is tapped. then have the boe-bot use the tap count to start a sub routine. i have used a couple of diff count methods but i have yet to over come the contact bounce.

here is what i think is my best script. i would much rather have a percise count so i can have many more options.

Comments

  • hawkhunterhawkhunter Posts: 18
    edited 2012-09-03 22:14
    ' 
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    
    ' count number of tapps on the tacktical whisker then proform action in 
    ' accordance with count outcome
    
    selection       var      word
    
    count 5,5000,selection
    
    pause 20
    
    
    IF selection =< 50 then 
        gosub  programe_1
     else
    
    
    IF selection > 50 then 
     gosub  programe_2
    endif
    endif
    
    program_1: 
     debug cr, ? selection 
     debug cr, "program 1"
    end
    
    program_2: 
     debug cr, ? selecton 
     debug cr, "program 2"
    end
    
  • hawkhunterhawkhunter Posts: 18
    edited 2012-09-03 23:57
    well looks like i got the counting cleaned up.
    ' BUTTON.BS2
    ' Connect an active-low circuit to pin P5 and p7 of the BS2. When you press the
    ' button p5 , the DEBUG screen will display a count of how many times you pushed the button.
    ' the p7 BUTTON will execute the program corrasponding to the amount of times you pushed the
    ' button.  I used the whiskers as the buttons
    
    
    
    
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    
    Btn             PIN     5
    Btn2            PIN     7
    btnWrk          VAR     Byte
    btn2Wrk         VAR     Byte
    counter         VAR     Word
    
    
    Main:
    
    
      PAUSE 50
      BUTTON Btn, 5, 255, 20, btnWrk, 0, No_Press
      counter = counter + 1
      DEBUG CR, ? counter
    
    
    
    
    No_Press:
        PAUSE 50
      BUTTON Btn2, 7, 255, 20, btn2Wrk, 0, goto_main
      IF counter = 1 THEN
      GOTO main
      ENDIF
      DEBUG CR, "this should start program 1"
      GOTO program_1
    
    
    
    
     goto_main:
          GOTO Main
    
    
    program_1:
        DEBUG CR, ? counter
        DEBUG CR, "if counter printed then this might work"
      IF counter = 1 THEN GOTO main
        IF counter = 2 THEN GOTO tactile_whiskers
        IF counter = 3 THEN GOTO phototransistor
        IF counter = 4 THEN GOTO infra_red
        IF counter => 5 THEN GOTO TO_many_button_pushes
    
    
    
    
    tactile_whiskers:
      DEBUG CR, "tactile_whiskers code would exacute"
    
    
    END
    
    
    phototransistor:
       DEBUG CR, "phototransistor code would exacute"
    END
    
    
    infra_red:
       DEBUG CR, "infra_red code would exacute"
    
    
    END
    
    
    TO_many_button_pushes:
      DEBUG CR, "you pushed the button more times than you have programs"
    
    
    END
    
    
    
  • ercoerco Posts: 20,257
    edited 2012-09-04 04:17
    You could also use IR and a remote at the start to select which sub program to branch to. Works great.
  • hawkhunterhawkhunter Posts: 18
    edited 2012-09-04 04:46
    as im building this bot i realy got to wonder if they ever intended for all these sensors and resistors to be used at the same time. that sure is a lot of bare wire in close proximate to each other. still working on getting the IR hoked up.
  • ercoerco Posts: 20,257
    edited 2012-09-04 09:04
    Yes, you have to be very careful not to bump the many wires when you handle it. It's a great learning platform and designed for easy building, which means easy (and unintended) disassembly too. Another good reason to use IR is so you don't have to reach inside that jumble of wiring to push a button and accidentally knock a wire loose in the process. :)

    If you're already using the Boebot's IR proximity sensors, you have all the hardware you need. You can use those same sensors to receive IR signals from a TV remote control. It's all in the Boebot book.
  • walkin79walkin79 Posts: 29
    edited 2012-09-05 23:27
    ' ' {$STAMP BS2}' {$PBASIC 2.5}' count number of tapps on the tacktical whisker then proform action in ' accordance with count outcomeselection var wordcount 5,5000,selectionpause 20IF selection =< 50 then gosub programe_1 elseif selection =>50 then gosub program_2endifprogram_1: debug cr, ? selection debug cr, "program 1"program_2: debug cr, ? selecton debug cr, "program 2"end
Sign In or Register to comment.