• Blog
  • About Esrun
  • Blackhat SEO Scripts
  • Contact

First arduino project – Security light

September 14, 2011 on 12:22 pm | No Comments

I’ve been pretty busy with client work lately and haven’t had much time to blog about seo stuff. I’ve got some interesting things on the go related to clickjacking and XSS for seo purposes, they should make for some interesting posts in the future.

For now, I’m spending what little free time I have playing with my Arduino (a clone, Gizduino).

I made my first project outside of the examples, which is of course pretty basic. It uses a photoresistor to sense when someone walks by and turns on an LED for 2 seconds.

What is it?

The project uses a green LED and photoresistor. The photoresistor measures the light in the room and turns on an LED for 2 seconds when there’s a certain variance in the light reading (e.g someone walking past the sensor, reducing the amount of light it senses). The readings taken from the photoresistor are also sent over Serial to be viewed on the computer.

Where could you use this?

This kind of setup is typically used in automatic roof air fresheners; I have one made by Glade that will spray each time you walk past it, up to a maximum of once per 30 minutes. You also find the same technology used in hand dryers, no-touch toilet flushers and many other places.

Finished project

Here’s a picture of my Gizduino with an LED connected to digital pin13 and ground and a photoresistor connected to analog pin0 and 5v and a resistor connected between ground and analog pin0.

 

Video

Here’s a video of the project in action. It could do with a little refinement but since it’s just a fun test project, I wont be improving on it.

 

And here is the code used for the project. Bear in mind that this was just a quick test project thrown together in about 10 minutes. I’m sure there are perfections that could be made.

void setup() {
  Serial.begin(9600);
  pinMode(13, OUTPUT);
}

void loop() {
  int sensorValue = analogRead(A0);
  Serial.println("First Reading: ");
  Serial.println(sensorValue);

  delay(10);

  int sensorValue2 = analogRead(A0);

  if(sensorValue - sensorValue2 > 5){
    Serial.println("Detected movement!");
    digitalWrite(13, HIGH);
    delay(2000);
    digitalWrite(13, LOW);
  } 

  Serial.println("Second Reading: ");
  Serial.println(sensorValue2);
}

It’s basic but it’s a nice beginners project to test reading analog components and getting used to coding the Arduino.

No Comments yet »

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code lang=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>