Shop OBEX P1 Docs P2 Docs Learn Events
Defcon Badge + PIR sensor — Parallax Forums

Defcon Badge + PIR sensor

prontopronto Posts: 1
edited 2012-09-02 13:04 in Propeller 1
http://learn.parallax.com/kickstart/555-28027 <<

so i was able to get it working with my normal dev board (p8x32a)
http://pronto185.com/parallax/animation_1346611479916.gif
L
EDs on = movement, off = no movement
OBJ

  pst : "Parallax Serial Terminal"  ' Use Serial Terminal object


CON


  _clkmode = xtal1 + pll16x           ' Set clock mode
  _xinfreq = 5_000_000
  
VAR


  byte state                          ' Variable for storing PIR output
  
PUB PIR 
  dira[17] := 1
  dira[18] := 1
  dira[22] := 1
  dira[21] := 1
  outa[17] := 0
  outa[18] := 0
  dira[0] := 0                            ' Set pin 0 to input
  pst.start(115200)                   ' Start Terminal at 115200 baud
  pst.str (string("Warming up..."))                                                           
  waitcnt(clkfreq * 20 + cnt)   ' PIR "warm-up" time
  pst.clear                           ' Clear the screen


  repeat
    state := ina[0]                   ' Save state of PIR Sensor
    pst.home                          ' Move cursor to upper left
    pst.str(string("IN0 = "))
    pst.bin(state, 1)                 ' Display results
    waitcnt(clkfreq/200 + cnt)  ' Small delay\
   if state == 1
    outa[17] := 1
    outa[18] := 1
    outa[22] := 0
    outa[21] := 0        
   else
    outa[17] := 0
    outa[18] := 0
    outa[22] := 1
    outa[21] := 1 
  
    

(changed code a bit from whats shown on the gif, but still same concept)



now when i try to do this on my defcon badge , it's not working.

i have it connected correctly (used one of those pinout diagrams posted)
http://i.imgur.com/QjwrS.jpg
Sign In or Register to comment.