Skip to content

Commit f88df61

Browse files
committed
returning errors on sound effects
-all sound effects now return errors -checked for errors in sound effect example
1 parent cd10f72 commit f88df61

File tree

3 files changed

+202
-79
lines changed

3 files changed

+202
-79
lines changed

examples/Example_08_Sound_Effects/Example_08_Sound_Effects.ino

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ QwiicBuzzer buzzer;
3535

3636
#define kBuzzerVolume 4 // loudest!!
3737
//#define kBuzzerVolume 3 // pretty good volume for most things
38+
sfeTkError_t err; // used for checking for errors
3839

3940
void setup() {
4041
Serial.begin(115200);
@@ -53,7 +54,14 @@ void setup() {
5354
{
5455
Serial.print("Sound Effect: ");
5556
Serial.println(i);
56-
buzzer.playSoundEffect(i, kBuzzerVolume);
57+
err = buzzer.playSoundEffect(i, kBuzzerVolume);
58+
59+
// Check whether the playSoundEffect() was successful
60+
if (err != kSTkErrOk)
61+
{
62+
Serial.println("error!");
63+
break;
64+
}
5765
delay(2000);
5866
}
5967
}

0 commit comments

Comments
 (0)