Is that buzzer buzzing on its own if you connect it to 5V ?The Tone() library is to generate a tone to a loudspeaker.
Still don't understand why I cant connect it to a pin and ground, set the pin high and achieve the same result as connecting it directly to a battery.
1. Maybe there was an error in your code. Did you remember to set the pinMode to OUTPUT?2. Maybe the buzzer takes too much current for the pin to supply. Did you measure the voltage on the pin?