Introduction: Arduino - Simple Security Idea.
What I wanted was a simple motion sensor that I could use semi-remotely. You can get airfresheners, pir sensors and all kinds of things to work, but I wanted something simple and cheap that could be used remotely. Pir sensors cost close to ten dollars each retail. Harbor freight had a whole setup for just ten dollars (on sale) for the price of a pir sensor, so I could not pass it up.
Note: Try this at your own risk. Get a professional to help if you are unsure.
Update: There is now a product from Seeed that is a clone of the arduino. Stores are discounting the regular arduino simce the Seeeed items are about half the cost of the Arduino.
Note: Try this at your own risk. Get a professional to help if you are unsure.
Update: There is now a product from Seeed that is a clone of the arduino. Stores are discounting the regular arduino simce the Seeeed items are about half the cost of the Arduino.
Step 1: What's Needed.
Arduino.
LDR.
1K resistor.
Wire.
Black tape.
Driveway Alert system.
3 "C' cell batteries
1 9V battery
Moc
2 - 330 ohm resistors
1 - 3k resistor
Breadboard for testing
1 parallel port break out cable.
LDR.
1K resistor.
Wire.
Black tape.
Driveway Alert system.
3 "C' cell batteries
1 9V battery
Moc
2 - 330 ohm resistors
1 - 3k resistor
Breadboard for testing
1 parallel port break out cable.
Step 2: Main Circuits.
There are two circuits here. One from the Arduino to the receiver and the other from the Arduino to the pc. I did not want to have to deal with rs232 circuits so just a simple signal to the parallel port should do the job.
Note: resistor from the Arduino to the MOC could be as low as 330 ohms.
Note: resistor from the Arduino to the MOC could be as low as 330 ohms.
Step 3: The Code.
Arduino
[code]
int ldr = 0; //analog pin to which LDR is connected
int ldr_value = 0; //variable to store LDR values
int ledPin = 12;
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}
void loop()
{
ldr_value = analogRead(ldr); //reads the LDR values
if (ldr_value > 50)
{
delay(50); //wait
digitalWrite(ledPin, HIGH); // sets the LED on
delay(5000); // waits for 5 seconds before rearming
digitalWrite(ledPin, LOW); // sets the LED off
}
}
[/code]
PC (freebasic)
[code]
do until 0 <> 0
do until (res AND 64) = 6
res = INP(&H379)
rem 64 is for pin 10 if it goes high
loop
rem execute whatever code you want to let you know there was motion.
rem bti sends a twitter to the set up account.
shell "echo there was motion | bti"
rem Timing loop before rearming.
for z = 1 to 500000
next z
loop
[/code]
[code]
int ldr = 0; //analog pin to which LDR is connected
int ldr_value = 0; //variable to store LDR values
int ledPin = 12;
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}
void loop()
{
ldr_value = analogRead(ldr); //reads the LDR values
if (ldr_value > 50)
{
delay(50); //wait
digitalWrite(ledPin, HIGH); // sets the LED on
delay(5000); // waits for 5 seconds before rearming
digitalWrite(ledPin, LOW); // sets the LED off
}
}
[/code]
PC (freebasic)
[code]
do until 0 <> 0
do until (res AND 64) = 6
res = INP(&H379)
rem 64 is for pin 10 if it goes high
loop
rem execute whatever code you want to let you know there was motion.
rem bti sends a twitter to the set up account.
shell "echo there was motion | bti"
rem Timing loop before rearming.
for z = 1 to 500000
next z
loop
[/code]
Step 4: Test It.
It works!





