This code is getting the value from the switch widget and assigning it to the variable ‘x’. If your switch is set-up in the normal way then this will be. 0 (off) or a 1 (on).
As I said in an earlier post, it would help if you used meaningful variable names rather than just ‘x’. If your button on V0 is used to activate/deactivate the alarm system then change the name of variable ‘x’ to ‘alarm_activated’. That way, your code will be much more readable.
if i turn on the button in the app (v0) the alarm gets activated with notifications but even if i dont connect pir sensors i still get messages that there is motion on pirsensor 1,2,3 random without any sensor connected so the code is doing that on its own?
are these wired with pull-down resistors (as you are looking for the pins to become HIGH)? If not then the pins are floating and that may be causing your issue.
He will still have an issue if he doesn’t implement pull-down resistors. As the 3 input pins will be floating. His serial monitor will be putting out 0 and 1 randomly.
If he adds a relay/led it will chatter/pulse when the PIR is not detecting motion.
That is a good question. And if they happen to be able to send a LOW signal upon detection of motion, he can use the ESP’s builtin pull-up resistors and save on the hardware/wiring requirements.
Hi i had seen this video i uses his training he explanes so good and thank for pointing this out … ik think my sensors are high all the time thas what we gone try with wickedbeernut sugestion…