This is example how to use ESP Easy rules on ESP Witty (ESP8266). It shows timer, events, and assigning value to "variable".
The pins are connected as below:
- GPIO4 - Push Button
- GPIO12 - Green LED
- GPIO13 - Blue LED
- GPIO15 - Red LED
One device is set to Switch input and it is named button with "1st GPIO" set to GPIO-4. You cannot have variables, but You can have dummy device to store values. So I've created Dummy Device with name zmienna and set "Value Name 2" to indeks. In this example this dummy device is "Task" 3.
How it works?
If you push button the one LED is turn on for 1 second. If you push it again the next LED is turn on.
On button#Switch do
if [button#Switch]=0.00
event zgas
// increment task 3, value 2
TaskValueSet,3,2,[zmienna#indeks]+1
event zapal
endif
endon
// turn on one LED
on zapal do
timerSet,1,1 // timer 1, one second
if [zmienna#indeks] > 2
// reset counter
TaskValueSet,3,2,0
endif
if [zmienna#indeks] = 0
gpio,12,1 // Green
endif
if [zmienna#indeks] = 1
gpio,13,1 // Blue
endif
if [zmienna#indeks] = 2
gpio,15,1 // Red
endif
endon
On Rules#Timer=1 do
event zgas
endOn
// turn off all LEDs
on zgas do
gpio,12,0
gpio,13,0
gpio,15,0
endon
Add comment