Update relay.ino

Includes major bug fix by JohnHoward from the arduino forums.