how to use a speaker?

dear

Each note has to have a "duration". In your code you are turning on and of the speaker just once. this produces the click you hear. You need to loop that click multiple times in order for it to become an audible sound.