Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- "Flackerlicht zu Dauerlicht" by redled - 01/2012
- minzeit_on = 55 -- min Impulszeit für ON in ms
- maxzeit_on = 100 -- max Impulszeit für ON in ms
- minzeit_off = 120 -- min Impulszeit für OFF in ms
- maxzeit_off = 250 -- max Impulszeit für OFF in ms
- fzeit = 1500 -- Flackerzeit vor Dauer-ON (Summe aus Zufallszahlen nach minzeit, maxzeit)
- pstop = ("bottom") -- Eingang Programmstop
- flstr = ("back") -- Eingang Flackerstart
- flout = ("top") -- Flackerlicht Ausgang
- shell.run("clear")
- print(newline)
- print("-----------------------------------------")
- io.write(" Flackerlicht->Dauerlicht bei Start ")
- print("-----------------------------------------")
- print(newline)
- print("Eingang " .. flstr .. " = H: aktiv")
- print("Eingang " .. pstop .. " = H: Programmende")
- print("Ausgang " .. flout .. " = Flackerausgang")
- redstone.setOutput(flout, false)
- z = 0
- while not redstone.getInput(pstop) do
- if redstone.getInput(flstr) then
- sleep(0.4)
- while z < fzeit do
- randon = math.random(minzeit_on,maxzeit_on)
- pauseon = (randon / 1000)
- redstone.setOutput(flout, true)
- sleep(pauseon)
- redstone.setOutput(flout, false)
- randoff = math.random(minzeit_off,maxzeit_off)
- pauseoff = (randoff / 1000)
- sleep(pauseoff)
- z = (z + (randon + randoff))
- end -- while
- redstone.setOutput(flout, true)
- else
- redstone.setOutput(flout, false)
- z = 0
- end -- if
- sleep(0.5)
- end -- while not
- redstone.setOutput(flout, false)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement