I'm very new with Arduino, but I'd like to learn faster. Sorry for my ignorance.
I compiled the following sketch
#include <avr/pgmspace.h>
const word song[] PROGMEM = {1318,187,1760,187,1318,187,1975,187,1318,187,1568,187,
1760,187,1318,187,2092,187,2349,187,1318,187,1975,187,2092,187,1318,187,1975,187,
1318,187,1760,187,1318,187,1568,187,1760,187,1318,187,2092,187,1318,187,2349,187,
1318,187,1975,187,2092,187,1975,187,1318,187,1760,187,1318,187,1975,187,1318,187,
1568,187,1760,750,0,0};
void setup(void)
{
Serial.begin(9600);
byte pntr = 0;
word note;
word duration;
while (1){
note = pgm_read_word_near(song + pntr);
duration = pgm_read_word_near(song + pntr + 1);
Serial.print(note);
Serial.print("\t");
Serial.print(duration);
Serial.print("\t");
Serial.println(pntr);
if ((!note && !duration) || pntr > 255) break;
tone(8, note, duration);
pntr += 2;
noTone(8);
}
noTone(8);
}
void loop(void)
{
}
The data seen over the serial monitor are pretty correct.
I can hear the click, but no sound is played.
If I load a standard example like toneMelody, then it plays nicely with a mediocre volume.
Am I missing something ?