Page 1 of 1

esp + rgb led strip (addresable) + hcsr04

Posted: 06 Nov 2019, 15:55
by bartezzz
Hello All!

Im loking for kind of advice, direction how to, or maybe better idea than mine.

from begining i want to put led rgb strip on stairs , but not on each steps just along entire lenght of the stairs(300 cm), hscr04 on top of the stairs which will measure distance between person on stairs and sensor and lit up part of strip where person actually is with of course one step backward and forward, in total one step with brightness to 100% and backward and forward step with brightness of 50%. i want to put it in rules to make it working , but found out couple issue which i couldnt resolve with my current expierence... so i add device (hcsr04) named numerLED in values puted %value%/1.67 (1.67cm is the distance between two led on strip) , this is bringing me value which led need to be lit up, i used command into rules neopixel[numerLED#distance],255,255,255 which works fine . my question is i want add now another command neopixelLine which will turn on for example 5leds backward and forward , should i add another device hcsr04 and put in values %values%/1.67+5 %values%/1.67-5 ? i try to use dummy device , but it is not accepting symbols like -+/. another question turning it on looks quite easy to do, but i struggle how to turn it off when you already passed couple steps ...

apreccicate for any comment and help

Re: esp + rgb led strip (addresable) + hcsr04

Posted: 07 Nov 2019, 22:37
by bartezzz
at the moment i stuck in one place
i create couple lines of rules, which works great,

rules1:

On HCSR04#distance do

if [hcsr04#distance]>0

TaskValueSet 1,1,[hcsr04#Distance]/1.67
taskvalueset 1,2,[numerled#1]-5
taskvalueset 1,3,[numerled#1]+5
neopixelline,[numerled#2],[numerled#3],120,120,120
neopixel,[numerled#1],250,250,250

endif
endon

this is what log shows:

3721174 : EVENT: hcsr04#Distance=180.00
3721226 : ACT : TaskValueSet 1,1,180.00/1.67
3721241 : Command: taskvalueset
3721258 : ACT : taskvalueset 1,2,108-5
3721273 : Command: taskvalueset
3721289 : ACT : taskvalueset 1,3,108+5
3721304 : Command: taskvalueset
3721321 : ACT : neopixelline,103,113,120,120,120
3721348 : ACT : neopixel,108,250,250,250

my qyestion is, how to turn them off when value of hcsr04 will change
so basically what i want to achive is when distance changed, currently led which are on will turn off and another part of led strip will turn on.

kind regards