i barrely have enough room for the arduino, and all servo wires, so there is no room for an mp3 player/card reader with amplifier - would an esp32 be better? because it has integrated wlan, so theroreticaly it could acces a media server of me and than play that sound file?
The video shows a good way to kill an Arduino pin.
Connecting the base of a transistor to a pin, with the emitter to ground, is worse than connecting a LED to a pin without resistor.
The author doesn't know what he is doing, don't copy him.
The smallest speaker driver I can think off is a complementary pair (NPN + PNP).
Easier for the arduino pin, and the 100uF cap keeps DC off the speaker.
A BC547/548 pair is just OK, but use a less fragile BC327/BC337 pair if you can.
Leo..
An alternative that allows the use of a simple circuit, is to use a piezo buzzer instead of a speaker.
There are two types of piezo buzzer:
Passive: the Arduino board must oscillate the buzzer using tone. This allows you to control the tone from your sketch code. You can obtain higher volume without extra components by driving it with two digital pins on the Arduino board instead of one: toneAC v1.2 - Twice the volume, higher quality, higher frequency, etc.
Active: an oscillator circuit is built into the buzzer module. You only need to provide the buzzer with power to make it sound. These are fairly loud.
The cheapest piezo buzzers are the passive disc alone:
Isn't Arduino and the maker movement all about messing with things we don't know, and thus gaining that knowledge?
But I don't mean to dismiss your suggestion. An amplifier module is surely a great option for anyone who would prefer to focus their energy on other aspects in their learning journey than audio amplifier circuits!
If you use "trial and error" methods, yes, but in these cases many components will have to be thrown away because they will break (assuming they don't burn or explode)... I call it the "Electroboom method", if you know him...
The LM386 is specified for operation up to 12 V or 18 V.
with that "LM386" i still dont need an mp3 player?(on amazon are five for 7 bucks) how much more loudness can i expect from it? i read people complain that 5v from usb is not enough, so it needs the full 12v?
The LM386 is like the L293; old bjt technology.
There are much more modern class-D amplifiers that will output twice the power at half the supply voltage, like the PAM8403 (ebay, etc).
Leo..
An LM386 is meant for amplifying low level analog signals. Operated at 5V, it can have no useful effect on a 5V PWM signal, which is obvious if you think about for a moment.
Have you considered wiring up a stereo plug and feeding signal to powered speakers or if you want loud, an amp or soundboard cause it scales up right off the shelf.
The circuit I posted is nothing more than a complementary (double) emitter follower to increase current capability of the Arduino pin. I guess OP makes the pew-pew sound with the "tone" function or something similar. Driving a 8 Ohm (speaker) load was the problem, and that seems to be solved.
Leo..
An Arduino pin can't supply more than 40mA.
That translates to a minimum load resistance of 5V / 0.04A = 125 Ohm.
Not a good idea to connect an 8 Ohm speaker directly to the pin.
The transistors amplify the current, taking the load off the Arduino pin.
One transistor for the HIGH pulse, the other one for the LOW pulse.
See Google images for "Class B amplifier".
Leo..