Joprp05:
Is it really needed and why of that?Also, because it is a electromagnetic buzzer, it won’t be able to create electricity when it tap it, right?
Yes, needed. That buzzer draws ~100mA peak, and a pin is rated for 40mA absolute max.
Use e.g. a 2N2222. Emitter to ground, base with a ~470ohm resistor to pin, collector to buzzer negative.
Buzzer positive to 5volt, diode (1N4148) across buzzer to protect the transistor.
Not possible to use this buzzer as microphone.
Leo..