Intel® Edison Hands-on Day 6: Sensor Lamp

Published

Introduction: Intel® Edison Hands-on Day 6: 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

Step 1: Connection

PIR Motion Sensor → Digital Pin 2

Digital piranha LED light module Digital Pin 13

Step 2: Coding

int 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.

Step 3: 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.

Share

    Recommendations

    • Woodworking Contest

      Woodworking Contest
    • Make it Move Contest

      Make it Move Contest
    • Clocks Contest

      Clocks Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    Comments