Page 1 of 1

Turning LED on and off based on LCD status

Posted: 11 Sep 2016, 16:48
by BasemAlsaeed
hi there,
i have a Display connected I2C and there is a button configured to turn on the Display for 5 seconds, i am wondering if there is a way that i can turn an LED connected to GPIO 5 when the Display is turned on and turn the LED of after the LCD turn off ?
thanks

Re: Turning LED on and off based on LCD status

Posted: 11 Sep 2016, 23:39
by BasemAlsaeed
Ok, i found a solution
I found that if I create a device with a SWITCH input type for the GPIO connected to Display on/off button (in my case the button is connected to GPIO 4) I can use it in rules based on its state
now my rule is like this:

on s1#switch do
gpio,5,1
timerSet,1,4
endon
On Rules#Timer=1 do
gpio,5,0
endon

my next step is that i want to replace the physical button with a touch sensor KY036, and hopefully when i touch the face-plate of the screen it turns on along with illuminating buttons
any ideas ? :)

Re: Turning LED on and off based on LCD status

Posted: 12 Sep 2016, 00:12
by BasemAlsaeed
Well, now everything is working as i want, i connected the KY036 touch sensor to GPIO 4, and configured a new device as a Switch type "Push Button Active Low", and then i modified my rule to be :
on s1#switch do
gpio,5,1
lcdcmd,on
timerSet,1,10 //Set Timer 1 for the next event in 4 seconds
endon
On Rules#Timer=1 do //When Timer1 expires, do
gpio,5,0
lcdcmd,off
endon

now when i touch the sensor, both LED and Display turn on for the time i define in the timerset 1