# Haunt Controller



## Dead Things (Apr 4, 2009)

Here is a vid of my completed Haunt Controller.






Here is the code that i used. Much gratitude to Steve O for all his help.

Code:
_________________________________________________________

let dirsb=%00001111
let pinsb=%00000000
let w0 = time
symbol sequence =w0
symbol debounce =b3
symbol adc_val =b8
random w1
pause w2

waiting: 
random w1
readadc C.0,adc_val
if adc_val<8 then waiting
debounce =debounce +1 
pause 100
if debounce >9 then Show

Show: gosub Clear_debounce
random sequence
let pinsb =sequence
random w1
w2=w1//3000 + 9000
pause 3000
random sequence
let pinsb =sequence
random w1
w2=w1//3000 + 9000
pause 3000
pinsb=0
pause 1000
goto waiting

Clear_debounce:
debounce = 0
return
______________________________________________________


----------



## Wildcat (Nov 3, 2007)

Very cool set up.


----------



## hpropman (Jul 27, 2008)

Nice job on the controller!


----------



## JeffHaas (Sep 7, 2010)

Nice controller!

About the PIR...I first played with these last year, and found them to be annoying because they didn't act predictably. You didn't mention which one you were using, but I had the Parallax version I got at Radio Shack. I eventually found this code that discards a range of inaccurate responses and once I used it, the whole thing worked great:
http://www.arduino.cc/playground/Code/PIRsense

This is for the Arduino, but I think someone (SteveO?) should be able to port it over to Basic and give it a try.

The other thing to do with a PIR is to put it in a plastic tube or cap, so it can only see in a narrow line ahead of it. Otherwise it will see things way off to the side and that can make it unreliable too.

Using both these together made my PIRs work reliably last year.


----------



## Dead Things (Apr 4, 2009)

Thanks Jeff, this is the one I'm using, I have it in a plastic cap but I'm sure the problem is in the coding. Will look around on the Picaxe forum, they may have a code.
http://www.electronics123.com/s.nl/it.A/id.62/.f


----------

