Hi to all,
I have a PCF8574 IO Expander that connected to Nodemcu. An IR Infrared Obstacle Avoidance Sensor Module (at picture) and a relay module is connected to the PCF8574 IO Expander. I want the relay to turn on once I show my hand to the sensor. I want the relay to stay on until I show my hand once again. Then when I show my hand to the sensor once more, I want the relay to turn off again, and keep it going like this. What should my rule be like?
PCF8574 IO Expander rule help
Moderators: grovkillen, Stuntteam, TD-er
PCF8574 IO Expander rule help
- Attachments
-
- module.jpg (26.3 KiB) Viewed 4171 times
-
- ESP_Easy.png (19.21 KiB) Viewed 4171 times
Re: PCF8574 IO Expander rule help
It could be as simple as this:
(relay assumed to be on pin 2 of the PCF8574)
- When the sensor turns on switch the relay to the inverse state
NB: You ill have to set a quite short on-time for the sensor, as you can only switch the relay once the sensor is back to 1 (off) again.
NB2: If the sensor is active-high, change the 'on sensor#State= do' to 'on sensor#State=1 do'
Code: Select all
on sensor#State=0 do // Sensor activated
pcfgpio,2,=![relay#State] // Flip relay
endon
- When the sensor turns on switch the relay to the inverse state
NB: You ill have to set a quite short on-time for the sensor, as you can only switch the relay once the sensor is back to 1 (off) again.
NB2: If the sensor is active-high, change the 'on sensor#State= do' to 'on sensor#State=1 do'
/Ton (PayPal.me)
Re: PCF8574 IO Expander rule help
Thank you very much, it worksAth wrote: ↑27 Apr 2021, 17:40Code: Select all
on sensor#State=0 do // Sensor activated pcfgpio,2,=![relay#State] // Flip relay endon
Who is online
Users browsing this forum: Bing [Bot] and 98 guests