else digitalWrite(ledPin, LOW); if (pirState == HIGH) Serial.println("Motion stopped."); pirState = LOW;
void loop() val = digitalRead(pirPin);
if (val == HIGH) digitalWrite(ledPin, HIGH); if (pirState == LOW) Serial.println("Motion detected!"); pirState = HIGH; pir sensor library for proteus
delay(100); // Small delay for stability else digitalWrite(ledPin, LOW); if (pirState == HIGH) Serial
/* * PIR Motion Sensor Simulation for Proteus * Output: LED on Pin 13 turns ON when motion detected */ int pirPin = 2; // PIR output pin int ledPin = 13; // Built-in LED int pirState = LOW; // Current state of PIR int val = 0; // Reading from PIR if (pirState == HIGH) Serial.println("Motion stopped.")
else digitalWrite(ledPin, LOW); if (pirState == HIGH) Serial.println("Motion stopped."); pirState = LOW;
void loop() val = digitalRead(pirPin);
if (val == HIGH) digitalWrite(ledPin, HIGH); if (pirState == LOW) Serial.println("Motion detected!"); pirState = HIGH;
delay(100); // Small delay for stability
/* * PIR Motion Sensor Simulation for Proteus * Output: LED on Pin 13 turns ON when motion detected */ int pirPin = 2; // PIR output pin int ledPin = 13; // Built-in LED int pirState = LOW; // Current state of PIR int val = 0; // Reading from PIR