Aayush Sharma
Published © GPL3+

Motion Sensing Gallery Lights Using MSP 430 or Arduino UNO

Usefull project when you wake up at night for washroom the PIR Sensor Senses your Motion and turns the tube light on.

IntermediateProtip3 hours191
Motion Sensing Gallery Lights Using MSP 430 or Arduino UNO

Things used in this project

Hardware components

PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
MSP-EXP432P401R SimpleLink MSP432 LaunchPad
Texas Instruments MSP-EXP432P401R SimpleLink MSP432 LaunchPad
×1
Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
4-CHANNEL RELAY CONTROLLER FOR I2C
ControlEverything.com 4-CHANNEL RELAY CONTROLLER FOR I2C
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Energia
Texas Instruments Energia
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Digilent Screwdriver
Digilent Screwdriver
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires

Story

Read more

Schematics

circuit diagram

ckt dia

Code

motion sensing automated lights

C/C++
code for the motion sensing automated lights
/*
* PIR sensor tester
*/
 
int ledPin = P1_2; // choose the pin for the LED
int inputPin = P1_5; // choose the input pin (for PIR sensor)
int pirState = true; // we start, assuming no motion detected
int val = 0; // variable for reading the pin status
int minimummSecsLowForInactive = 5000; // If the sensor reports low for
// more than this time, then assume no activity
long unsigned int timeLow;
boolean takeLowTime;
 
//the time we give the sensor to calibrate (10-60 secs according to the datasheet)
int calibrationTime = 30;
 
void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT); // declare sensor as input
 
Serial.begin(4800);
 
//give the sensor some time to calibrate
Serial.print("calibrating sensor ");
for(int i = 0; i < calibrationTime; i++){
Serial.print(".");
delay(1000);
}
Serial.println(" done");
Serial.println("SENSOR ACTIVE");
delay(50);
}
 
void loop(){
val = digitalRead(inputPin); // read input value
if (val == HIGH) { // check if the input is HIGH
digitalWrite(ledPin, LOW); // turn LED ON

delay(30000);

delay(30000);

delay(30000);

delay(30000);



if (pirState) {
// we have just turned on
pirState = false;
Serial.println("Motion detected!");
// We only want to print on the output change, not state
delay(50);
}
takeLowTime = true;
} else {
digitalWrite(ledPin, HIGH); // turn LED OFF
 
if (takeLowTime){
timeLow = millis();
takeLowTime = false;
}
 
if(!pirState && millis() - timeLow > minimummSecsLowForInactive){
pirState = true;
Serial.println("Motion ended!");
delay(50);
}
 
}
}

Credits

Aayush Sharma

Aayush Sharma

2 projects • 7 followers
My name is Aayush Sharma ..I love to work with Electronics and make cool and awesome gadgets. i create random project tutorial videos.

Comments

Add projectSign up / Login