Problem when using PROGMEM on array holding notes for speaker on Arduino
You can not directly dereference something ("access an array") that is in flash memory. You have to use pgm_read_xxx functions from &lt;avr/pgmspace.h> .

In your case you should probably write something like this:

tone(8, pgm_read_word(&amp;melody[thisNote]), noteDuration);


Pgm_read_word reads two bytes. You could also call that inside your tone() function, the function would take the pointer in flash as an argument.

I would also recommend you using integer types from &lt;stdint.h>, because they have defined sizes. Pure int is most likely 32-bit on your PC, but 16-bit on the AVR (I have learned this the hard way when my algorithm ran fine on the PC but gave totally junk output on the AVR).