Created
September 9, 2018 01:34
-
-
Save giljr/d2ef699aa3d22a4e570b9c355e688c44 to your computer and use it in GitHub Desktop.
https://medium.com/jungletronics/arduino-multi-file-sketch-583a7833162c Arduino Multi File Sketch
This file contains hidden or 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
class PIR { | |
private: | |
int _ledPin; | |
int _pirPin; | |
int _pirState; | |
public: | |
void PIR_Setup(int ledPin, int pirPin, int pirState) { | |
_ledPin = ledPin; | |
_pirPin = pirPin; | |
_pirState = pirState; | |
pinMode(ledPin, OUTPUT); //PIR Setup | |
pinMode(pirPin, INPUT); | |
} | |
void PIR_Loop() { | |
int pirValue = digitalRead(_pirPin); //PIR Loop | |
if (pirValue == HIGH) { // check if the input is HIGH | |
digitalWrite(_ledPin, HIGH); // turn LED ON | |
if (_pirState == LOW) { | |
_pirState = HIGH; | |
} | |
} else { | |
digitalWrite(_ledPin, LOW); // turn LED OFF | |
//lcd.print("Motion ended! "); | |
_pirState = LOW; | |
} | |
} | |
void PIR_Display() { | |
if (_pirState == HIGH) { | |
lcd.print("Motion detected!"); | |
//break; | |
}; | |
if (_pirState == LOW) { | |
lcd.print("Motion ended! "); | |
//break; | |
} | |
} | |
}; | |
PIR PIR; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment