Charlie Evans Project 1 – Cat Catcher 3000!

Our first physical computing project was to create a system/product that utilised either 2 inputs and 1 output or vice versa.

Our basic Arduino set only gave us limited sensors to play with, which have already been covered in practice, so I decided to purchase a PIR sensor. This is an infra red detector to pick up motion, my aim being to use this (the 1 input) to detect motion and raise an alarm using an LED and buzzer (the 2 outputs).

With this arrived I was able to wire them all to the Arduino UNO. Firstly I coded the PIR to trigger the buzzer only by using ‘if’ statements, and then added the red LED. With this all working as planned I knocked together a small housing for it all with holes for the PIR and LED.

Pictures show some of the building or the circuit and of the housing, plus a video to show how it all worked!

Coding:

int pirPin = 2;
int pinSpeaker= 10;
int ledPin = 13;
void setup(){
Serial.begin(9600);
pinMode(pirPin, INPUT);
pinMode(ledPin, OUTPUT);
pinMode(pinSpeaker, OUTPUT);
}
void loop(){
int pirVal = digitalRead(pirPin);
Serial.println(“starting to read PIR”);
analogWrite(ledPin, 0);
delay(2000);
if(pirVal == LOW) {
analogWrite(ledPin, 255);
Serial.println(“Motion Detected”);
tone(10, 700, 100);
delay(2000);
}
}
void tone(long duration, int freq) {
duration *= 1000;
int period = (1.0 / freq) * 1000000;
long elapsed_time = 0;
while (elapsed_time < duration) {
digitalWrite(pinSpeaker,HIGH);
delayMicroseconds(period / 2);
digitalWrite(pinSpeaker, LOW);
delayMicroseconds(period / 2);
elapsed_time += (period);
}
}

Photo 25-02-2015 12 59 17Photo 25-02-2015 12 59 59Photo 25-02-2015 13 01 09Photo 25-02-2015 13 04 26

This first project helped reinforce what Id learnt in the lectures leading up to and throughout it, it also widened my knowledge of components and possible projects as I researched online and spoke to my peers.

If I were to re do this project Id try and use more complex code to possibly have different outputs, and would try add another input such as a distance sensor, or the PIR on a servo to scan the area and give it a larger area to detect.

https://www.youtube.com/watch?v=-2sZCSObTc0

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s