lovelymondayss

pertemuan 5

Nov 4th, 2022
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. int pinSensor =7;
  2. int pinState=0;
  3. void setup() {
  4. Serial.begin(9600);
  5. pinMode(pinSensor, INPUT);
  6. }
  7. void loop() {
  8. pinState=digitalRead(pinSensor);
  9. //if pir state is high then motion is detected
  10. if (pinState==HIGH){
  11. Serial.println("Motion Detected");
  12. delay(100);
  13. }else{
  14. Serial.println("No Motion Detected");
  15. delay(100);
  16. }
  17. }
  18.  
Add Comment
Please, Sign In to add comment