Created
October 4, 2023 13:19
-
-
Save oleingemann/b44b6624d519be1db93a3f11350a4e37 to your computer and use it in GitHub Desktop.
Arduino - Infrarød PIR-bevegelsessensor med LED-lys
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int PIR_SENSOR_OUTPUT_PIN = 2; /* PIR-sensorens output-signal */ | |
void setup() { | |
pinMode(PIR_SENSOR_OUTPUT_PIN, INPUT); | |
pinMode(13, OUTPUT); | |
Serial.begin(9600); /* Definerer porten til seriell-lesning */ | |
delay(3000); /* Gir arduinoen 3 sek på å starte opp */ | |
} | |
void loop() { | |
int sensor_output; | |
sensor_output = digitalRead(PIR_SENSOR_OUTPUT_PIN); | |
if( sensor_output == LOW ) | |
{ | |
digitalWrite(13,LOW); | |
Serial.print("Helt stille her, jeg ser ingenting.\n\n"); | |
delay(200); //0.2 sekunders pause | |
} | |
else | |
{ | |
digitalWrite(13,HIGH); | |
Serial.print("Observasjon!\n\n"); | |
delay(200); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment