Picaxe PIR interface
mcnultyr
Posts: 1
Hello,
··· I've purchased·a few PIR sensors from Parallax, and was hoping maybe·someone could help me with my program. I'm using two sensors facing opposite directions to trigger a servo motor to move left or right. I need some programming help...
··· I'm using an 18x picaxe chip and programming in visual basic. My sensors are hooked to In1 and In2. My servo motor is hooked to out1. Running 5V.
·main:
··· if pin1 = 1 then
··· servo 1, 80
··· pause 2000
··· elseif pin1 = 0 then
··· endif
··· if pin2 = 1 then
··· servo 1, 80
··· pause 2000
··· elseif pin2 = 0 then
··· endif
goto main
Please tell me what you think of my code - if·ANYONE could give me a better example code, that would really help me out. Thank you so much!
·Ryan McNulty
530-205-7473
··· I've purchased·a few PIR sensors from Parallax, and was hoping maybe·someone could help me with my program. I'm using two sensors facing opposite directions to trigger a servo motor to move left or right. I need some programming help...
··· I'm using an 18x picaxe chip and programming in visual basic. My sensors are hooked to In1 and In2. My servo motor is hooked to out1. Running 5V.
·main:
··· if pin1 = 1 then
··· servo 1, 80
··· pause 2000
··· elseif pin1 = 0 then
··· endif
··· if pin2 = 1 then
··· servo 1, 80
··· pause 2000
··· elseif pin2 = 0 then
··· endif
goto main
Please tell me what you think of my code - if·ANYONE could give me a better example code, that would really help me out. Thank you so much!
·Ryan McNulty
530-205-7473
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike2545
This message sent to you on 100% recycled electrons.
Hi,
Saw your code ... made a few changes to turn ON/OFF an LED on my AXE091 development board;
#picaxe 18M2
;#terminal 9600
#terminal 76800
pause 20000
; BEGIN Main Body * * * * * * * * * * * * * * * * * * * * * * * * * * *
do
if pin1 = 1 then high b.4
elseif pin1 = 0 then low b.4
endif
debug
loop
; END Main Body * * * * * * * * * * * * * * * * * * * * * * * * * * **
Still, it doesn't seem to be working ... have you found a good working solution for the PIR on a PICAXE ???
http://www.Brainless.org/
This thread is from 2009 and the OP is long gone.
Nevermind!
A few things. First, this is a Parallax forum. You would be better served in the Picaxe forum but since you do have Parallax sensors we'll try to help a bit. A few observations:
1) Please describe exactly what you are trying to do.
2) You have a servo and an input on pin 1. Please use Picaxe's port+pin format (like pinC.1, etc ) for your inputs.
3) Both of your SERVO commands are exactly the same: SERVO 1, 80. Even if your program branches properly according to the inputs, nothing will happen.
4) You should initialize your servo early in the program with the SERVO command, then use SERVOPOS thereafter for smoothest servo action.