so you're watching that sci-fi movie and you say "hey dude, *****wood's at it again with all their studio tricks...HOW THE **** DID A LIGHT COME ON WHEN THIS DUDE WALKED BY?"
well, believe it, it's no trick!
why? 'cos that's what you are about to see... READY?
WHAT YOU NEED TO PERFECT YOUR OWN *****WOOD TRICK?
- your arduino board+cable
- breadboard
- 10k resistor
- PIR motion sensor
- jumper wire
HERE IS THE SKETCH
/* using pir motion sensor to off and ON an led connected to pin 3 of the arduino...
AUTHOR: ANIEROBI PETER
DATE: 4/23/2014
www.hub360.blogspot.com, www.facebook.com@hub360
*/
int motion =4; // pir motion sensor connected to analog pin 4
int led = 3;// led connected to pin 3
int x;
void setup(){
pinMode(motion,INPUT); //set pir as input
pinMode(led,OUTPUT); //set led as output
}
void loop(){
x= digitalRead(motion); //read to know if motion is detected or not
digitalWrite(led,x); //ON or OFF an LED according to detection
}
NOTE:
- WHEN CONNECTING YOUR COMPONENTS, THE VCC OF THE PIR IS CONNECTED TO 5V PIN ON THE ARDUINO BOARD
- THE GROUND OF THE PIR IS CONNECTED TO THE GROUND PIN OF THE ARDUINO
- THE OUT OF THE PIR IS CONNECTED TO PIN4MOF THE ARDUINO
- THE ANODE (POSITIVE LEG) OF THE LED IS CONNECTED THROUGH A 220OHM RESISTOR TO PIN3 OF THE ARDUINO
- THE CATHODE (NEGATIVE) OF THE LED IS CONNECTED TO THE GROUND OF THE ARDUINO
A. LED (ON THE BREAD BOARD) IS OFF DUE TO ABSENCE OF MOVING OBJECT
B. LED (ON THE BREAD BOARD) COMES ON AS IT SENSES MOVING OBJECT
don't forget...
think...create...repeat
team hub360
No comments :
Post a Comment