Visit my website for help and downloads...
http://www.juanjolopez.net/index.php/pr ... styler-dmx
by Juanjo Lopez

More info about Lua...
http://www.lua.org/about.html
Code: Select all
--[[ rainbow_motion.lua: cycles through the colors of the rainbow
This script written for RGB LED Strip Lights that have a number of IC chips,
but should also work with a series of 3 channel RGB Lights]]--
DMXstart = 25 --> DMX start address
Channels = 3 -- number of channel per LED
IChips = 131 --> number of IChips on your strip, look good on shorter strips too
DMXend = DMXstart + (Channels* IChips) - 1
delay = 20 --> User Input, milliseconds, used for timing speed
step = 12 --> User Input, number of steps between primary and secondary colors
-- steps that work: 4, 6, 7, 9, 12, 14, 18, 21, 28, 36 --
--[[ if anybody can rework this script so that STEP variable can be
any integer between 1 and 36 or more, please post,
as I'm a bit stumped]]--
bump = math.floor(255 / step)
top = step * bump
--**Length must as long or longer then the strip
if (step * 6) / IChips < 1 then Length = IChips / (step * 6);
Length = math.ceil(Length) * (step * 6) * Channels;
else Length =(step * 6)/ IChips * IChips;
Length = math.ceil(Length) * Channels;
end
Length = math.ceil(Length) -- of rainbow pattern
t = {}
z = nil
color = {g = 0, r = top, b = 0} --colors on my strip are arranged GREEN RED BLUE
count = 1
Print(Length)
--start
Print("START")
while (StopButton()==0) do
for c=1,Length,3 do --this loop writes all GRB values to a Table Array
if color.g ~= top and color.r == top and color.b == 0 then --Red first
t[count] = color.g
t[count + 1] = color.r
t[count + 2] = color.b
count = count + 3
color.g = color.g + bump
else if color.g == top and color.r ~= 0 and color.b == 0 then
t[count] = color.g
t[count + 1] = color.r
t[count + 2] = color.b
count = count + 3
color.r = color.r - bump
else if color.g == top and color.r == 0 and color.b ~= top then --Green
t[count] = color.g
t[count + 1] = color.r
t[count + 2] = color.b
count = count + 3
color.b = color.b + bump
else if color.g ~= 0 and color.r == 0 and color.b == top then
t[count] = color.g
t[count + 1] = color.r
t[count + 2] = color.b
count = count + 3
color.g = color.g - bump
else if color.g == 0 and color.r ~= top and color.b == top then --Blue
t[count] = color.g
t[count + 1] = color.r
t[count + 2] = color.b
count = count + 3
color.r = color.r + bump
else if color.g == 0 and color.r == top and color.b ~= 0 then
t[count] = color.g
t[count + 1] = color.r
t[count + 2] = color.b
count = count + 3
color.b = color.b - bump
end
end
end
end
end
end
end
break
end
-----------FUNCTIONS--------------------------------------------------------------
Pixels = function(c)
fsSetOutput(c,t[count]) fsSetOutput(c+1,t[count+1]) fsSetOutput(c+2, t[count+2])
end
-------------------
StripRefresh = function() --> moves all values in Table Array ahead one place,
for x=1,3,1 do -- and pastes what's dropped off the end to the front
z = ( t[Length] )
table.insert(t,1,z)
table.remove(t)
end
end
-----------------------------------------------------------------------------
count = 1
repeat
for c=DMXstart,DMXend,3 do --> This loop outputs the whole strip
Pixels(c)
count = count + 3
end
Sleep(delay)
count = 1
StripRefresh()
until (StopButton()~=0)
--end
Print("STOP")
--set all output channels to 0 --> turn off the lights
for c=DMXstart,DMXend,1 do
fsSetOutput(c,0);
end