Shop OBEX P1 Docs P2 Docs Learn Events
Build-Your-Own-Door-Alarm + Movement PING-servo — Parallax Forums

Build-Your-Own-Door-Alarm + Movement PING-servo

thomas_pittinthomas_pittin Posts: 29
edited 2014-01-19 23:43 in General Discussion
Hello,

I would like to add an istruction in this program "Build-Your-Own-Door-Alarm"

The istruction that I want to add is to rotate(45° -45° ) the PING sensor in order to "view" all the object, but I don't know how can I do

Comments

  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-01-17 16:05
    Kind of a suspicious file. The extension shows .bs2 but when trying to save or open it comes up as a .php file. Anyone else ge same results?
  • RDL2004RDL2004 Posts: 2,554
    edited 2014-01-17 16:16
    I had no problems.

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    
    ' -----[ Title ]-----------------------------------------------------------
    ' DoorAlarm.bs2
    ' Monitors a doorway until an object is in the way, then an alarm sounds,
    ' and the number of triggers are recorded and displayed to the LCD.
    
    
    ' -----[ Variables ]-------------------------------------------------------
    
    time         VAR   Word            ' Round trip echo time
    intruderCnt  VAR   Byte            ' Count of alarm triggers
    counter      VAR   Word            ' Counter for FOR...NEXT loop
    
    ' -----[ Constants ]-------------------------------------------------------
    
    maxDist      CON   2000            ' Maximum distance for alarm trigger
    
    ' -----[ Jolly Roger Custom Characters ]-----------------------------------
    
    SEROUT 12, 84, [248, %00000, %11000, %11000, %01100,       ' Top left
                    %01110, %11011, %11001, %00000]            ' crossbone
    
    SEROUT 12, 84, [249, %00000, %11001, %11011, %01110,       ' Bottom left
                    %01100, %11000, %11000, %00000]            ' crossbone
    
    SEROUT 12, 84, [250, %00000, %01110, %11111, %11111,       ' Top half
                    %10101, %10101, %11111, %01110]            ' of skull
    
    SEROUT 12, 84, [251, %01110, %11111, %11111, %10001,       ' Bottom half
                   %10001, %11111, %01110, %00000]             ' of skull
    
    SEROUT 12, 84, [252, %00000, %00011, %00011, %00110,       ' Top right
                    %01110, %11011, %10011, %00000]            ' crossbone
    
    SEROUT 12, 84, [253, %00000, %10011, %11011, %01110,       ' Bottom right
                    %00110, %00011, %00011, %00000]            ' crossbone
    
    ' -----[ Initialization ]--------------------------------------------------
    
    SEROUT 12, 84, [22,12]             ' Initialize LCD
    PAUSE 5
    
    intruderCnt = 0                    ' Reset intruder count to 0
    
    ' -----[ Main Routine ]----------------------------------------------------
    
    DO
      PULSOUT 15, 5                              ' Send pulse
      PULSIN  15, 1, time                        ' Read echo time
    
      IF (time < maxDist) THEN                   ' If alarm is triggered...
        intruderCnt = intruderCnt + 1
    
        SEROUT 12, 84, [128, 0, 129, 2, 130, 4,  ' Display Jolly Roger
                        148, 1, 149, 3, 150, 5]
        SEROUT 12, 84, [132, DEC intruderCnt,    ' Display number of alarm
                        " intruders "]           ' triggers on the LCD
        SEROUT 12, 84, [153, "detected!! "]
    
        FOR counter = 0 TO 3
          FREQOUT 4, 500, 3800                  ' Play alarm tone
          PAUSE 100
          HIGH 1                                ' Flash LEDs
          HIGH 5
          FREQOUT 4, 500, 2700                  ' Play lower tone for variety
          PAUSE 100
          LOW 1                                 ' Flash LEDs
          LOW 5
        NEXT
    
      ELSEIF (intruderCnt = 0) THEN
        SEROUT 12, 84, [128, 0, 129, 2, 130, 4,  ' Display Jolly Roger
                        148, 1, 149, 3, 150, 5]
        SEROUT 12, 84, [133, "Alarm",
                        153, "Armed!"]
        SEROUT 12, 84, [141, 0, 142, 2, 143, 4,  ' Display Jolly Roger
                        161, 1, 162, 3, 163, 5]
      ENDIF
    
      PAUSE 100
    LOOP
    
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-01-17 21:58
    I just upgraded to IE 11. Gee, I wonder if that could be it??????
  • thomas_pittinthomas_pittin Posts: 29
    edited 2014-01-19 23:13
    Is there anyone that can help me?
  • RDL2004RDL2004 Posts: 2,554
    edited 2014-01-19 23:43
    You will need to have the Ping mounted on a servo in order to have it scan back and forth. There is some sample code for use with the Boe-bot that includes scanning back and forth with the Ping. You can probably adapt parts of that code. You can find it at this link:

    http://www.parallax.com/downloads/roaming-ping-advanced-basic-stamp-code

    "http://www.parallax.com/downloads/roaming-ping-advanced-basic-stamp-code&quot;
Sign In or Register to comment.