4D LearningFRC 6429 4th Dimension

Arduino deneyi 18

PIR Motion Alarm

Intermediate · 45 min · Motion sensing

Detect movement with a PIR sensor and trigger a small buzzer or LED.

Sesli anlatım videosu (İngilizce, sentetik ses). Çekim videosu eklenince yerini alır.

Malzemeler

  • Arduino Uno
  • PIR motion sensor
  • Active 5V buzzer or LED with 220 Ω resistor
  • Jumper wires

Bağlantı

  1. Connect PIR VCC to 5V, GND to GND and OUT to pin 2.
  2. Connect a low-current active buzzer to pin 8 and GND, or use an LED with a resistor.

Kod

const int pirPin = 2, alarmPin = 8;

void setup() {
  pinMode(pirPin, INPUT); pinMode(alarmPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  bool motion = digitalRead(pirPin);
  digitalWrite(alarmPin, motion);
  if (motion) Serial.println("Motion detected");
  delay(100);
}

Ne olmalı?

After its warm-up period, the PIR activates the output when movement is detected.

Meydan okuma

Keep the alarm active for five seconds after the last movement.

Güvenlik ve sorun giderme

  • Bağlantıyı değiştirmeden önce gücü kes.
  • Her LED ile direnç kullan.
  • Kart ve port seçimini Arduino IDE'de kontrol et.
  • Her kablonun koddaki pin numarasıyla eşleştiğini doğrula.

Not: Ders metinleri İngilizcedir. Orijinal Türkçe çalışma kâğıdı PDF olarak indirilebilir.