Christmas Lights and Music Display

Have jolly jolly Christmas and Happy New Year!

Christmas Lights and Music Display

Things used in this project

 

Hardware components

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

Story

 

Simple Christmas Lights and music player turned on by Arduino whenever PIR sensor detects movement in the hallway.

 

http://www.crosspantry.com/IMG_2132.MOV

 

Schematics

 

PIR Sensor Front

 

 

PIR Sensor back

 

 

PIR to Arduino Wiring

 


 

Code

 

Arduino Sketch

Arduino

CODE
/*
 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
  }
}
  

The article was first published in hackster, January 8, 2016

cr: https://www.hackster.io/pinpin/christmas-lights-and-music-display-885214

author: Kate Appel

License
All Rights
Reserved
licensBg
0