$USD
  • EUR€
  • £GBP
  • $USD
TUTORIALS IoT

Intel® Edison Hands-on Day 6: Sensor lamp

DFRobot Nov 03 2014 259

Sensor lamp
In this section we will try to make a sensor lamp. When someone passes by the sensor lamp, the LED will be automatically on. Of course, it will be off if nobody is around. We select PIR motion sensor in this example. It allows you to detect whether someone has moved in or out of the sensors range. It is a good choice for April Fools~~
 
Tools required



Connection
PIR Motion Sensor  →  Digital Pin 2
Digital piranha LED light module  →  Digital Pin 13



Codingint sensorPin = 2;             // PIR Motion Sensor Pin int ledPin =  13;               //LED Pin int sensorState = 0;           //Store the PIR Motion Sensor State void setup() {  pinMode(ledPin, OUTPUT);         //LED is an output device  pinMode(sensorPin, INPUT);      // The Sensor is an input device } void loop(){  sensorState = digitalRead(sensorPin);  //Read the sensor state  if (sensorState == HIGH) {       //If the sensor state is HIGH, turn on the LED    digitalWrite(ledPin, HIGH);  }  else {                               //otherwise turn off the LED    digitalWrite(ledPin, LOW);  } }
   After uploading the sketch, trying to go away from the sensor and wait a moment. Pay attention to the LED and it will be off. If you get close to the sensor, the LED will be on automatically.
 
 
Principle?Digital Input—Digital Output?
There is three parts of the device, input part, controlling part and output part. PIR Motion Sensor is the input part. Edison is the controlling part. LED is the output part
PIR Motion Sensor is a digital sensor, and LED is also a digital device.


 

REVIEW