I am not sure about your code, but if you are driving your relay with a transisitor, use 100uF capacitor on the base of the transistor (before the resistor). This is to avoid "buzzing" as you say.

<a href="http://img7.picsplace.to/img7/24/TR_Drv.GIF"><img src="http://img7.picsplace.to/img7/24/thumbs/TR_Drv.GIF" alt="Image Hosting by PicsPlace.to" ></a>