This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Random RGB color script for LM Ambient
#1
1. Specify RGB grp address in LM-Wall --> LED config
2. Add the following Resident script with 0 interval

Code:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
math.randomseed(os.time()) function init_color()    color = {}    color.r = math.random(0,10)*25    color.g = math.random(0,10)*25    color.b = math.random(0,10)*25    return color end function RGB(r,g,b)     color = 0    color = bit.lshift(bit.band(r,0xFF),16) + bit.lshift(bit.band(g,0xFF),8) + bit.band(b,0xFF)    return color end function linear(c1,c2,k)    return (c2 - c1)*k + c1 end if src == nil then    src = init_color() end dst = init_color() time = 4 delay = 0.2 steps = time/delay k = time / delay for i = 0,steps do    r = linear(src.r,dst.r,i/steps)    g = linear(src.g,dst.g,i/steps)    b = linear(src.b,dst.b,i/steps)   end        grp.update('RGB LED',RGB(r,g,b))    os.sleep(delay)             end src = dst os.sleep(delay)
Reply


Messages In This Thread
Random RGB color script for LM Ambient - by edgars - 09.12.2015, 11:01

Forum Jump: