An active buzzer has a built-in oscillator with a fixed frequency. The buzzer is simply turned on and off by powering it with a +5V source to one lead and connecting the other lead to ground (GND).
In the Elegoo Kit Lesson 6 sketch, the active buzzer is driven through a digital output pin, which is turned on and off to produce an alarm-like result.
A passive buzzer has no built-in oscillator. Instead, it will produce sounds by driving it with square waves at different frequencies.
In the Elegoo Kit Lesson 7 sketch, the Arduino tone
function is used to produce sounds at different frequencies. The “pitches.h” header file must be loaded from the Elegoo library files in order to compile the sketch. Alternately, a sequence of frequencies can simply be specified in the melody array at the top of the sketch.
Passive buzzers generally have a limited range of frequencies they can produce and the sound quality is poor.