const int pirPin = 3; // Pin PD3 connected to PIR sensor
void setup() {
pinMode(pirPin, INPUT); // Set PIR pin as input
Serial.begin(9600); // Start serial communication
}
void loop() {
int pirState = digitalRead(pirPin); // Read the PIR sensor
// طباعة القيمة لمعرفة إذا كانت تتغير عند اكتشاف الحركة
Serial.println(pirState);
if (pirState == HIGH) {
// Motion detected
Serial.println("Motion Detected!");
} else {
// No motion detected
Serial.println("No motion detected");
}
delay(500); // Delay to prevent flooding serial monitor
}
const int ledPin = A0; // Pin D7 connected to LED
void setup() {
pinMode(ledPin, OUTPUT); // Set LED pin as output
digitalWrite(ledPin, HIGH); // Turn ON the LED
}
void loop() {
// لا حاجة للكود في الloop، الـ LED سيظل مضاءً
}