-
-
Save yarogniew/91738022adf26c800129576bf809715b to your computer and use it in GitHub Desktop.
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
/*========================== | |
Czujnik ruchu RCWL-0516 | |
Czujnik - D2 | |
LED (yellow) - D13 | |
============================*/ | |
int Sensor = 2; | |
int led = 13; | |
int blk = 0; // blokada pętli | |
void setup() { | |
Serial.begin(9600); | |
pinMode (Sensor, INPUT); | |
pinMode (led, OUTPUT); | |
} | |
void loop() { | |
bool val = digitalRead(Sensor); // stan sensora | |
if((val > 0) && (!blk)) | |
{ | |
digitalWrite(led, HIGH); | |
Serial.println("Wykryto ruch"); | |
blk = 1; | |
} | |
if(val == 0 && blk) | |
{ | |
digitalWrite(led, LOW); | |
Serial.println("Brak ruchu"); | |
blk = 0; | |
} | |
delay(50); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment