Shop OBEX P1 Docs P2 Docs Learn Events
Picaxe PIR interface — Parallax Forums

Picaxe PIR interface

mcnultyrmcnultyr Posts: 1
edited 2014-07-16 13:47 in Accessories
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

Comments

  • FranklinFranklin Posts: 4,747
    edited 2009-04-20 16:37
    If it's programming help you want why not post in a picaxe forum? http://www.picaxeforum.co.uk/

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Mike2545Mike2545 Posts: 433
    edited 2009-04-22 22:07
    I have not had experience with the Picaxe but I think Franklin has the right Idea.

    Happeh_Tard_by_Davidgtza2.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike2545

    This message sent to you on 100% recycled electrons.
  • wperkowperko Posts: 66
    edited 2014-07-16 13:07
    mcnultyr wrote: »
    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


    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/
  • ercoerco Posts: 20,255
    edited 2014-07-16 13:47
    Edit: wperko, I took your bait.

    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.
Sign In or Register to comment.