Making Furniture Interactive

September 11, 2007

Exercise 2: Red Alert Security System

Filed under: Exercise 2: Add a Switch — architk @ 10:44 pm


I created a security system that when someone or something approaches with any light, the Led light would change from green to blue and finally to red light indicating the warning of object or peerson nearby. I made 3 Led lights (Green, Blue, Red) to respond seperately according to the amount of light present that would be read by the photosensor. These lights are hooked up to arduino program which then directs certain Led light to switch on when it corresponds to sensor number I assigned. Green light would be always on when the value is less than 125 meaning there is not much light. Then Blue light would switch on when the value is bigger than 125 and less than 400. The red light would turn on when the value is greater than 400. So as I got closer with flashlight, the Led changed from green to blue to red. Serial monitor was really helpful to see the numbers or values change so that I could write the code that would perform desired effect. Here’s the diagram of wiring.


I also created a switch with copper strip that would be attached to door knob. when the door opens up and the door knob(in this case shown as a tennis ball) reaches the wire, it would trigger the security system.


 Below is the video link of my project.


int analogValue0 = 0;
int analogPin0 = 0;
int ledPinGreen = 13;
int ledPinRed = 7;
int ledPinBlue = 5;

void setup() {
  pinMode(analogPin0, INPUT);
    Serial.begin(9600); // Set up the serial communication.

void loop() {
  analogValue0 = analogRead(analogPin0);
  Serial.print(“Raw Sensor value: “);
  if (analogValue0 > 400) {
    digitalWrite(ledPinRed, HIGH);
  else {
    digitalWrite(ledPinRed, LOW);
  if (analogValue0 > 125&&analogValue0 < 400) {
    digitalWrite(ledPinBlue, HIGH);
  else {
    digitalWrite(ledPinBlue, LOW);
  if (analogValue0 < 125) {
    digitalWrite(ledPinGreen, HIGH);
  else {
    digitalWrite(ledPinGreen, LOW);


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s

Blog at

%d bloggers like this: