Skip to content

Instantly share code, notes, and snippets.

@sfambach
Created September 15, 2019 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sfambach/71043b4ce8c03482e6bedfaecd14373f to your computer and use it in GitHub Desktop.
Save sfambach/71043b4ce8c03482e6bedfaecd14373f to your computer and use it in GitHub Desktop.
/** HC SR501 Test
* www.fambach.net
* GPL V2
*/
#define SR501PIN A0
void setup() {
Serial.begin(115200);
// init pin
pinMode(A0, INPUT_PULLUP);
}
void loop() {
if (digitalRead(A0) == HIGH) {
Serial.print("PIR activated ...");
while (digitalRead(A0) == HIGH) {
//Serial.print(".");
}
Serial.println(" now inactive");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment