Piezo Buzzer

The code you've written there will (as far as I can tell) make a few clicks every few seconds. To make a plain piezo sounder beep, you must feed it with a square wave of a few hundred cycles per second. The data sheet for your buzzer recommends 2048Hz, in fact. And it states that the buzzer only needs 3 to 5 Volts to work properly. That data sheet also mentions that the device is not a high-impedance piezo sounder but a low-impedance magnetic buzzer. It's possible that 12V is too much for it!