Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

Interactive Project - Creating a Motion-Activated LED Strip

Importance and Utility of Interactive Projects

Interactive projects play a vital role in the field of electronics and engineering. They provide a hands-on experience for learners and allow them to explore the practical applications of various electronic components and programming concepts. These projects not only help in understanding the theoretical aspects but also enhance problem-solving skills and creativity.

Project: Motion-Activated LED Strip

In this project, we will create a motion-activated LED strip using Arduino. The LED strip will turn on automatically when motion is detected and turn off after a certain period of inactivity. This project can be used for various applications, such as lighting up a pathway, creating an interactive art installation, or enhancing home security.

List of Components:

Examples:

Example 1: Setting Up the Circuit

// Pin Definitions
const int pirPin = 2;     // PIR Motion Sensor Pin
const int ledPin = 3;     // LED Strip Pin

void setup() {
  pinMode(pirPin, INPUT);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  if (digitalRead(pirPin) == HIGH) {
    digitalWrite(ledPin, HIGH);
    delay(5000);  // LED remains on for 5 seconds
    digitalWrite(ledPin, LOW);
  }
}

Example 2: Adding Delay for Inactivity

// Pin Definitions
const int pirPin = 2;     // PIR Motion Sensor Pin
const int ledPin = 3;     // LED Strip Pin

void setup() {
  pinMode(pirPin, INPUT);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  if (digitalRead(pirPin) == HIGH) {
    digitalWrite(ledPin, HIGH);
    delay(5000);  // LED remains on for 5 seconds
    digitalWrite(ledPin, LOW);
  } else {
    digitalWrite(ledPin, LOW);
    delay(100);   // Delay for inactivity
  }
}

Example 3: Controlling LED Brightness

// Pin Definitions
const int pirPin = 2;     // PIR Motion Sensor Pin
const int ledPin = 3;     // LED Strip Pin

void setup() {
  pinMode(pirPin, INPUT);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  if (digitalRead(pirPin) == HIGH) {
    analogWrite(ledPin, 255);  // Full brightness
    delay(5000);               // LED remains on for 5 seconds
    analogWrite(ledPin, 0);    // Turn off the LED
  } else {
    analogWrite(ledPin, 0);    // Turn off the LED
    delay(100);                // Delay for inactivity
  }
}

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.