-- download at MT.QZX.COM (counter.lua) local c = 3 -- pulse and reset after C input pulses local o = "c" -- output pulse when reset local i = "d" -- input signal to count local s = "b" -- on/off switch or pressure plate if not mem.n then mem.n = 1 elseif event.iid == "lo" then port[o] = false elseif event.type == "on" and pin[i] and pin[s] then mem.n = mem.n + 1 if mem.n > c then mem.n = 1 port[o] = true interrupt(1, "lo") end end