You don’t need the pot. A single MOSFET is not a linear amplifier so the pot won’t work properly as a volume control, and you are more-likely to overheat the MOSFET.
Using the toneMelody example on Arduino IDE software,
You’ll probably have to go lower in frequency. The speaker has inertia… It will move enough to make sound at high frequencies but probably not enough to see. Try tone(31). That’s the lowest you can go with tone(). If that’s not low enough to see the speaker move, try the Blink Example. With a small speaker like that you won’t hear 31Hz (especially without a cabinet) but since it’s a square wave you will hear the harmonics.
Also try 5VDC directly from the power supply. You should see the speaker move when you connect and disconnect the power. (But don’t leave it connected too long.)
Not sure I totally understand the Ohms rule, but I thought the louder it would get is based on the voltage.
Yes. The volume depends on power (Watts) and frequency (and the efficiency of the speaker).
Ohm’s Law: Current (Amps) = Voltage/Resistance.
Power (Watts) = Voltage x Currnet
And with algebra you can derive:
Power (Watts) = Voltage2/Resistance
Power (Watts) = Current2 x Resistance
The DC resistance of a speaker is usually lower than the rated-nominal impedance.
The square wave is off half the time so you’re getting half the calculated power.
Speakers are rated for music. A 10 Watt amplifier that’s hitting 10W on the peaks is putting-out about 1W average. You can burn-out a “10W” speaker with constant 10W test-tones or 10W DC.