Advertisement
Muzze77

flacker by Redled72

Apr 7th, 2014
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.65 KB | None | 0 0
  1. -- "Flackerlicht zu Dauerlicht" by redled - 01/2012
  2.  
  3. minzeit_on =  55   -- min Impulszeit für ON in ms
  4. maxzeit_on =  100  -- max Impulszeit für ON in ms
  5. minzeit_off = 120   -- min Impulszeit für OFF in ms
  6. maxzeit_off = 250  -- max Impulszeit für OFF in ms
  7. fzeit =       1500 -- Flackerzeit vor Dauer-ON (Summe aus Zufallszahlen nach minzeit, maxzeit)
  8.  
  9. pstop = ("bottom")   -- Eingang Programmstop
  10. flstr = ("back")  -- Eingang Flackerstart
  11. flout = ("top")   -- Flackerlicht Ausgang
  12.  
  13.  shell.run("clear")
  14.  print(newline)
  15.  print("-----------------------------------------")
  16.  io.write("  Flackerlicht->Dauerlicht bei Start  ")
  17.  print("-----------------------------------------")
  18.  print(newline)
  19.  print("Eingang " .. flstr .. "  = H:  aktiv")
  20.  print("Eingang " .. pstop .. " = H:  Programmende")
  21.  print("Ausgang " .. flout .. "  =     Flackerausgang")
  22.  
  23.  redstone.setOutput(flout, false)
  24.  z = 0
  25.  
  26.  while not redstone.getInput(pstop) do
  27.      if redstone.getInput(flstr) then      
  28.         sleep(0.4)
  29.         while z < fzeit do
  30.               randon = math.random(minzeit_on,maxzeit_on)
  31.               pauseon = (randon / 1000)
  32.               redstone.setOutput(flout, true)
  33.               sleep(pauseon)
  34.               redstone.setOutput(flout, false)
  35.               randoff = math.random(minzeit_off,maxzeit_off)
  36.               pauseoff = (randoff / 1000)
  37.               sleep(pauseoff)
  38.               z = (z + (randon + randoff))
  39.         end -- while
  40.         redstone.setOutput(flout, true)              
  41.      else
  42.         redstone.setOutput(flout, false)
  43.         z = 0                          
  44.      end -- if      
  45.      sleep(0.5)      
  46.  end -- while not
  47.  redstone.setOutput(flout, false)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement