i exercised the code you posted simulating the ezButton and using pins on my hardware and it appears to work as you intended.
pressing and holding the button down causes the opto output pin to toggle after a delay ( 2.5 sec). briefly pressing the button causes the relay and led pins to toggle.
aren't pins 0/1 the serial rx/tx pins? try different pins