Add ability to inverse notify PIR LED (#765)
This commit is contained in:
3 files changed
+8
-1
No files matched your search
@@ -53,3 +53,6 @@ You can have another PIN mirror the value of the PIR sensor output by adding the
|
|||||||
This can be useful if you would like to connect an LED to turn on when motion is detected.
|
This can be useful if you would like to connect an LED to turn on when motion is detected.
|
||||||
|
|
||||||
`#define HCSR501_LED_NOTIFY_GPIO 4`
|
`#define HCSR501_LED_NOTIFY_GPIO 4`
|
||||||
|
|
||||||
|
This notification pin can be inverted if driving directly or through a transistor/mosfet.
|
||||||
|
`#define INVERT_LED_NOTIFY true`
|
||||||
@@ -63,7 +63,7 @@ void MeasureHCSR501() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
# ifdef HCSR501_LED_NOTIFY_GPIO
|
# ifdef HCSR501_LED_NOTIFY_GPIO
|
||||||
digitalWrite(HCSR501_LED_NOTIFY_GPIO, pirState);
|
digitalWrite(HCSR501_LED_NOTIFY_GPIO, pirState == HCSR501_LED_ON);
|
||||||
# endif
|
# endif
|
||||||
if (HCSR501data.size() > 0)
|
if (HCSR501data.size() > 0)
|
||||||
pub(subjectHCSR501toMQTT, HCSR501data);
|
pub(subjectHCSR501toMQTT, HCSR501data);
|
||||||
|
|||||||
@@ -33,6 +33,10 @@ extern void HCSR501toMQTT();
|
|||||||
#define subjectHCSR501toMQTT "/HCSR501toMQTT"
|
#define subjectHCSR501toMQTT "/HCSR501toMQTT"
|
||||||
//#define HCSR501_LED_NOTIFY_GPIO 4 //Uncomment this line to mirror the state of the PIR sensor to the specified GPIO
|
//#define HCSR501_LED_NOTIFY_GPIO 4 //Uncomment this line to mirror the state of the PIR sensor to the specified GPIO
|
||||||
|
|
||||||
|
#if defined(HCSR501_LED_NOTIFY_GPIO) && !defined(HCSR501_LED_ON)
|
||||||
|
# define HCSR501_LED_ON HIGH
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef TimeBeforeStartHCSR501
|
#ifndef TimeBeforeStartHCSR501
|
||||||
# define TimeBeforeStartHCSR501 60000 //define the time necessary for HC SR501 init
|
# define TimeBeforeStartHCSR501 60000 //define the time necessary for HC SR501 init
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in new issue
Block a user