Is this a correct way to connect an 8 ohm beaker to an Arduino?
https://www.c-sharpcorner.com/article/audio-play-using-sd-card-module-and-arduino/
Is this a correct way to connect an 8 ohm beaker to an Arduino?
https://www.c-sharpcorner.com/article/audio-play-using-sd-card-module-and-arduino/
To effectively drive a speaker from an Arduino you need an amplifier. The good ol' LM386 is a common choice for this (readily available and cheap, though not recommended for battery based projects).
While it is possible to drive a speaker directly it's not recommended. Not only is it very quiet, but also it can damage the IO pin. Not only from excess current draw (peak current at 5V through 8Ω [nominal] is 626mA, more than 15x the maximum the pin can supply, which not only stresses the pin but also distorts the output waveform) but a speaker is also an inductive load which has all the associated issues of back-EMF and such.
You had to put a resistor in serial with the speaker, Max current from the pin is 40 mA if put 8 ohm speaker on the pin it can't drive the speaker. Try a speaker with higher impedans.