#shorts
Автор: 3lectronical Gaming And Tech
Загружено: 2023-12-09
Просмотров: 226
Описание:
Today I will show you how to build a basic PIR motion sensor security alarm using an Arduino Uno, a Keyestudio PIR motion sensor and a buzzer. It can detect motion at up to 7m away.
code for this project:
// Define the pin connections
int pirSensor = 2; // Connect your PIR sensor to digital pin 2
int buzzerPin = 13; // Connect your buzzer to digital pin 13
void setup() {
pinMode(pirSensor, INPUT); // Set the PIR sensor pin as input
pinMode(buzzerPin, OUTPUT); // Set the buzzer pin as output
}
void loop() {
int sensorValue = digitalRead(pirSensor); // Read the value from the PIR sensor
if (sensorValue == HIGH) { // If the PIR sensor detects motion
digitalWrite(buzzerPin, HIGH); // Turn the buzzer on
} else { // If the PIR sensor doesn't detect motion
digitalWrite(buzzerPin, LOW); // Turn the buzzer off
}
delay(1000); // Wait for 1 second before the next reading
}
If you want to see other experiments that I have done, go to gronto.com.
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: