Kate Appel
Published

Christmas Lights and Music Display

Have jolly jolly Christmas and Happy New Year!

Showcase (no instructions)1,674
Christmas Lights and Music Display

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
Relay (generic)
×1
Christmas Lights
×1
Music Player
×1

Story

Read more

Schematics

PIR Sensor Front

PIR Sensor back

PIR to Arduino Wiring

Code

Arduino Sketch

Arduino
/*
 Author: Kate Appel
 Date: 2014
 Purpose: Motion Activated PowerRelay 
 Details: Arduino pin 2 get PIR sensor data and send to pin 3 digital LOW to Power Relay to turn it on
  */

int led1 = 3;           // the pin that the LED1 is attached to
static int state=0;
// the setup routine runs once when you press reset:
void setup()  { 
  // declare pin 3,6 to be an output:
  pinMode(2, INPUT_PULLUP);
  pinMode(led1, OUTPUT);
  Serial.begin(9600);
} 

void loop()  {
  int sensorValue = digitalRead(2);
  if(sensorValue)
  {
    digitalWrite(led1,LOW);//turn on the relay
    Serial.write("Motion\n");
    delay(30000);//wait for relay on for 30 seconds.
    state=1;
  }
  else  {
   Serial.println(sensorValue);
   digitalWrite(led1,HIGH);//turn off the relay
  }
}
  

Credits

Kate Appel

Kate Appel

5 projects • 3 followers
Software developer. B.S. Computer Science and Mathematics 1995, Univ. of Maryland. M.S. Computer Science 1998, Johns Hopkins Univ.

Comments