This video shows how to use a piezo buzzer with an arduino. This code and circuit can also be used with Arduino IDE/ Arduino Web Editor.
There are 2 ways to code a buzzer. Both ways are shown in video. The first way is using digitalWrite and the second way is using tone & noTone (recommended).
For the circuit:
Connect the negative pin of the buzzer to gnd and the positive to any digital pin(2-13). If using the second way use the digital pins with a '~' sign before them.