15.06.2022, 06:30
Erwin van der Zwart, thank you for your feedback.
Code:
percent_val = event.getvalue() -- your value
--the first 5-30%, the second between 35-70% and the third between 75-100%.
first_obj = '5/0/1' -- address of first object
second_obj = '5/0/2' -- address of second object
third_obj = '5/0/3' -- address of third object
if(percent_val >= 0 and percent_val < 5) then -- turn off
grp.write(first_obj, 0) -- first object set to 0
grp.write(second_obj, 0) -- second object set to 0
grp.write(third_obj, 0) -- third object set to 0
elseif( percent_val >= 5 and percent_val <= 30 ) then
grp.write(second_obj, 0) -- second object set to 0
grp.write(third_obj, 0) -- third object set to 0
os.sleep(1) -- delay to do not have two objects on simultaneously
grp.write(first_obj, 1) -- first object set to 1
elseif( percent_val >= 35 and percent_val <= 70 ) then
grp.write(first_obj, 0)
grp.write(third_obj, 0)
os.sleep(1)
grp.write(second_obj, 1)
elseif( percent_val >= 75 and percent_val <= 100 ) then
grp.write(first_obj, 0)
grp.write(second_obj, 0)
os.sleep(1)
grp.write(third_obj, 1)
end