Turning LED on and off based on LCD status

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
BasemAlsaeed
Normal user
Posts: 10
Joined: 11 Sep 2016, 16:43

Turning LED on and off based on LCD status

#1 Post by BasemAlsaeed » 11 Sep 2016, 16:48

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

BasemAlsaeed
Normal user
Posts: 10
Joined: 11 Sep 2016, 16:43

Re: Turning LED on and off based on LCD status

#2 Post by BasemAlsaeed » 11 Sep 2016, 23:39

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 ? :)

BasemAlsaeed
Normal user
Posts: 10
Joined: 11 Sep 2016, 16:43

Re: Turning LED on and off based on LCD status

#3 Post by BasemAlsaeed » 12 Sep 2016, 00:12

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

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 55 guests