Return to SDK Examples for Microchip Studio
#include "ClearCore.h"
#include "pitches.h"
const uint16_t melody[] = {NOTE_C4, NOTE_E4, NOTE_G4, NOTE_C5,
NOTE_CS4, NOTE_FS4, NOTE_AS4, NOTE_CS5,
NOTE_E4, NOTE_G4, NOTE_C5, NOTE_E5,
NOTE_FS4, NOTE_AS4, NOTE_CS5, NOTE_FS5
};
const uint32_t noteCount = sizeof(melody) / sizeof(melody[0]);
const uint32_t toneDuration = 200;
const int16_t toneAmplitude = INT16_MAX / 100;
#define tonePin ConnectorIO4
int main() {
tonePin.Mode(Connector::OUTPUT_TONE);
tonePin.ToneAmplitude(toneAmplitude);
while (true) {
for (uint8_t note = 0; note < noteCount; note++) {
tonePin.ToneContinuous(melody[note]);
}
tonePin.ToneStop();
}
}