http://forums.terraria.org/index.ph...3-1-wiring-mechanics.43646/page-2#post-982621 explains how to make things random(inside the spoiler)
In a simple case where x=5 and y=50, place dart trap, 5 second timer and any logic gate with an on lamp, off lamp and a faulty lamp on top. Wire timer to faulty lamp, gate to the dart trap. Turn on the timer. If you have very precise and non-integer x and y requirements it can get somewhat more complex. Hope this helps.
P.S. Don't forget dart trap ~3.3 seconds cooldown time