# Crow Killer gets a brain



## GOT (Apr 17, 2007)

It's all very exciting. My "Crow Killer" scarecrow ( http://www.hauntforum.com/showthread.php?t=29627 ) is going to be connected to a series of seven PIRs along the sidewalk. As kids walk by, the scarecrow will turn its head and track the kids. The question was how to efficiently hook up seven PIRs to a prop controller. After consulting with Otaku (thanks Otaku!) I came up with the following circuit. It uses a 74HC595 shift register to turn on and off the signals coming from the PIRs. That way, I can scan across the PIRs to see which are active in less than a second and load all the sensor states into a single Byte variable. Crow Killer will then make a decision (code not written yet) as to which sensor to look at. Here is the schematic and BS2 sub routine. I am sure there is room for improvement here. I chose my components based on what I had on hand and have really no idea how to design a proper circuit. The exciting part is that I built the circuit and it actually works! You need only 4 pins plus Vss and Vdd from your prop controller to control the whole thing. If you ganged up another 74HC595 chip, you could actually use this same setup with the same four pins to read up to 16 PIRs at once.










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

Dpin PIN 0
Latch PIN 1
Clock PIN 2

Trigger PIN 14

sensor VAR Byte
eyeball VAR Byte
counter VAR Nib

OUTS = %0000000000000000
DIRS = %0011111111111111

sensor = 0

Main:
sensor = 0
eyeball = %00000010 ' eyeball = 2. Pin 15 of the 74HC595 chip is actually output #1, so I have to start at 2 for this schematic. Pin 1 of the 74HC595 chip is output #2.
FOR counter = 1 TO 7
SHIFTOUT Dpin, Clock, MSBFIRST,[eyeball]
PULSOUT Latch, 1
PAUSE 50
IF (Trigger = 1) THEN
sensor = sensor + eyeball 'store active PIR in sensor variable bits %00000000
ENDIF
eyeball = eyeball << 1
NEXT
DEBUG ? sensor 'read out on your computer screen the value of "sensor"

PAUSE 1000

GOTO Main

I'll post a video once I get a little further along with the setup and will post my entire code once I write/debug it. By the way, you can build the circuit for $2.60 and get PIRs for about $3 each.

http://www.suntekstore.com/goods.php?id=14001941&utm_source=gbus


----------



## hedg12 (Jul 6, 2008)

Very cool! Can't wait to see the finished product!
Have you thought about how you're going to deal with multiple sensors triggering at once (kids at different places on the sidewalk at the same time)?


----------



## GOT (Apr 17, 2007)

hedg12 said:


> Very cool! Can't wait to see the finished product!
> Have you thought about how you're going to deal with multiple sensors triggering at once (kids at different places on the sidewalk at the same time)?


That will be the AI part. The prop will have to make some assumptions but will assume that a kid will generally walk from one end of the sidewalk to the other so he will first trigger PIR#1, then #2, then #3, etc. Crow Killer will ignore the other PIRs while this is happening. If there is a crowd, all of the PIRs will be active so he will just ignore everyone until the crowd goes away (he will occasionally scream at the crowd, though).


----------



## Otaku (Dec 3, 2004)

Looking good! I'm looking forward to seeing how this turns out, too. Great vision, nice execution.


----------



## RoxyBlue (Oct 6, 2008)

I am definitely wanting to see the video of this guy in action once you get it all worked out.


----------



## hedg12 (Jul 6, 2008)

GOT said:


> That will be the AI part. The prop will have to make some assumptions but will assume that a kid will generally walk from one end of the sidewalk to the other so he will first trigger PIR#1, then #2, then #3, etc. Crow Killer will ignore the other PIRs while this is happening. If there is a crowd, all of the PIRs will be active so he will just ignore everyone until the crowd goes away (he will occasionally scream at the crowd, though).


Cool - I figured it would be something like that. I'd be interested in seeing your code when you're done (if you're willing to share... )

What do you plan to use for a controller?


----------



## GOT (Apr 17, 2007)

Originally I was going to use a Prop-2, but the EFX controllers don't seem to work with the Parallax Servo Pals (the Servo Pals will let me move two servos simultaneously in BS2). So, I bought a Parallax "Board of Education". It will be controlling the PIRs, three servos, two motors and a sound board.


----------



## pshort (May 6, 2008)

Is that schematic the same as the circuit that you're testing? It seems to me that P14 will go high if any of the 595 outputs are high (as a result of the base current of the transistors), and will be in an indeterminate state when all of the 595 outputs are low (since there isn't anything to drive the P14 input low).


----------



## GOT (Apr 17, 2007)

That is the circuit though I do not show the Vss and Vdd connections to the PIRs. There is a transistor interrupting the signal from the PIRs. The 74HC595 chip sends out a signal to turn on and off each transistor individually in sequence and the prop controller looks to see if PIN14 went high as each transistor turned on (and records the result). I don't have anything driving PIN14 to low. I assumed it would go low automatically since it is designated as an input. Feel free to correct me if I am wrong as I am a complete novice here. I am in the early stages of testing but it appears to be working.


----------



## sluggo (Jun 16, 2010)

Is there some reason why you chose this configuration rather than connecting the signals from the PIRs directly to the shift register? Then, you could just read the status of all the PIRs by reading the value of the shift register. You wouldn't need the transisters and diodes with that setup. You'd need a different shift register, though. Just a thought.


----------



## pshort (May 6, 2008)

GOT said that he designed it based on the parts that he had on hand.


----------



## GOT (Apr 17, 2007)

The reason is that I don't know how to read the value of a shift register. I've only pushed data to them.


----------

