Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

motion following robot (PIR sensors)

Status
Not open for further replies.

banterbot

New Member
Hello,
I am currently working on making a robot that follows movement (people walking is my aim). I am using a boe-bot kit with a Basic Stamp 2 along with 3 PIR sensors (one on the front, one on the left and one on the right).
So far I have the boe-bot constructed and everything's been tested and working; I just need to configure the PIR sensors so that when movement is detected by any of the 3 PIR sensors, the robot will follow the direction of that movement and when that movement stops, the robot will stop too.
So, for example, when the left PIR sensor is detected, the robot should turn left to face that movement and then follow it until the movement either stops or changes directions.
This is the code I have thus far, but I feel it's missing something(s). Perhaps someone knows of some revisions that may help make my robot follow direction more clearly.

' {$STAMP BS2}
' {$PBASIC 2.5}

DEBUG "Program Running!"
DEBUG "Initialize"

PIRDetectLeft VAR Bit
PIRDetectRight VAR Bit
PIRDetectFront VAR Bit

irDetectLeft VAR Bit
irDetectRight VAR Bit
pulseCount VAR Byte

DO
PIRDetectLeft = IN15
PIRDetectRight = IN12
PIRDetectFront = IN14

IF (PIRDetectLeft = 1) AND (PIRDetectRight = 1) THEN

ELSEIF (PIRDetectLeft = 1) THEN
GOSUB Turn_Left
ELSEIF (PIRDetectRight = 1) THEN
GOSUB Turn_Right
ELSEIF (PIRDetectFront = 1) THEN
GOSUB Forward_Pulse
ENDIF

LOOP

Forward_Pulse:
PULSOUT 13,950
PULSOUT 12,750
PAUSE 10
RETURN

Turn_Left:
FOR pulseCount = 0 TO 10
PULSOUT 13, 750
PULSOUT 12, 750
PAUSE 10
NEXT
RETURN

Turn_Right:
FOR pulseCount = 0 TO 10
PULSOUT 13, 950
PULSOUT 12, 950
PAUSE 10
NEXT
RETURN

Back_Up:
FOR pulseCount = 0 TO 10
PULSOUT 13, 750
PULSOUT 12, 950
PAUSE 10
NEXT
RETURN
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top