Sunday, January 16, 2011

Project 4 - Motion Activated LED

Project 4 - Motion Activated LED

LED will blink if the Motion Sensor Detects Motion
int ledPin = 2; // Sets LED variable
int switchPin = 0; // Sets Motion Sensor variable
int value = 0; // Motion Sensor data variable

void setup() {
pinMode(ledPin, OUTPUT);
pinMode(switchPin, INPUT);
pinMode(4, OUTPUT);
void loop() {
value = digitalRead(switchPin); // Get data from Moton Sensor
if (HIGH == value) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);

This project uses a PIR Motion Sensor to detect motion and activate an LED. The Motion Sensor uses a 3 pin connector and is connected to the GND, VIN, and the digital 0 pin on the Arduino. While this setup is extremely simple, the motion sensor only detects motion or no motion. How fast or how far you move does not influence the LED in anyway.

I wish I could find the original source of who developed this simple motion sensing code, and I believe may have been a starting point while searching for this code example.

No comments:

Post a Comment