Willkommen auf unserem Seminar-Blog

Immer auf dem aktuellen Stand bleiben

Dieser Seminar-Blog befindet sich noch im Aufbau und wird in den kommenden Tagen entsprechend verfeinert.

Member Login

Lost your password?

Registration is closed

Sorry, you are not allowed to register by yourself on this site!

You must either be invited by one of our team member or request an invitation by email at viad.info {at} zhdk {dot} ch.

07 PIR Sensor

PIR Sensor

Aufgabe

Findet heraus, wie der Sensor an das Arduino angeschlossen wird und schreibt ein Programm, welches 1. Über Serial.print() ausgibt und 2. Eine LED anschaltet, wenn sich etwas im Sichtfeld des Sensors bewegt.

Informationen

Datenblatt Anleitung mit Code

Lösung

// AUFGABE 07: PIR Sensor 
// Embodied Interaction Basics
// Moritz Kemper, IAD Physical Computing Lab
// ZHdK, 09/11/2011

#define LED_PIN 13 // Define the Pin of the LED
#define PIR_PIN 8 // Define the Pin of the PIR Sensor (Type: Parallax 555-28027

void setup()
{
  pinMode(LED_PIN, OUTPUT); // Set the LED Pin as Output
  pinMode(PIR_PIN, INPUT); // Set the PIR Pin as Input
  digitalWrite(PIR_PIN, LOW); // Disable the Pullups
  
  delay(30000); // Wait for the Sensor to power up
  digitalWrite(LED_PIN, HIGH); // Say: Setup completed!
  delay(1000);
  digitalWrite(LED_PIN, LOW);
}

void loop()
{
  if(digitalRead(PIR_PIN) == HIGH) // If the PIR Pin goes HIGH
  {
    digitalWrite(LED_PIN, HIGH); // Set the LED to HIGH
    delay(100); // Wait for 100 Milliseconds 
  }
  else // If no Movement is detected anymore
  {
    digitalWrite(LED_PIN, LOW); // Turn off the LED
    delay(100); // Wait for 100 Milliseconds
  }
}

//Thats All ...