이 프로젝트에서는 재실 감지기로 집이나 실외에서 보호하는 방법을 살펴볼 것입니다. 모니터링하려는 공간에 아무도 없는지 확인하고, 감지되면 부저에서 알람을 울리고 액정 화면에 “ALERT”라고 표시하여 이를 알립니다.
이제 프로젝트에 필요한 장비를 나열하겠습니다:
전위차계는 화면 밝기를 조정하는 데 사용됩니다. 전위차계 없이도 5V를 갈색 선에 직접 연결하고 전위차계에서 화면으로 연결되는 GND를 아두이노 보드에 직접 연결할 수 있습니다.
#include <LiquidCrystal.h> // Library for LCD screen
LiquidCrystal lcd(13,12,6,5,3,2); // Initialize the library
int led = 7;
int PIR = 4;
int buzzer = 8;
int PIRstatus; // Variable to know if the PIR sensor detected motion or not
void setup()
{
lcd.begin(16,2); // Initialize the LCD screen
// Set the LED and buzzer as OUTPUT and the PIR as INPUT
pinMode(led, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(PIR, INPUT);
lcd.clear();
}
void loop()
{
PIRstatus = digitalRead(PIR); // Read the PIR sensor value
if (PIRstatus == HIGH) { // If the sensor detects motion
lcd.clear();
digitalWrite(led, HIGH);
digitalWrite(buzzer, HIGH); // Activate the buzzer
tone(buzzer, 300, 10000);
lcd.setCursor(0, 0);
lcd.print("ALERT"); // Display "ALERT" on the screen
delay(7000);
lcd.clear();
}
else
{
lcd.setCursor(0, 0);
lcd.print("SAFE"); // If no motion is detected, display "SAFE"
digitalWrite(led, LOW);
digitalWrite(buzzer, LOW);
}
delay(1000);
}
아두이노 보드에 프로그램을 설치하려면 아두이노 아이디어 소프트웨어가 필요합니다. 소프트웨어를 열고 프로그램을 로드한 다음 아두이노 보드를 연결하고 프로그램을 업로드하기만 하면 됩니다.