Skip to content

Commit 7d7633e

Browse files
author
brentru
committed
esp32-specific tone function in _zapier.ino
1 parent c4cb35f commit 7d7633e

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

examples/adafruitio_24_zapier/adafruitio_24_zapier.ino

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,14 @@ void loop()
177177
Serial.println("Switching to Task 1");
178178
// update the neopixel strip
179179
updatePixels(50, 0, 0);
180+
180181
// play a sound
181-
tone(PIEZO_PIN, 650, 300);
182+
#if defined(ARDUINO_ARCH_ESP32)
183+
ledcWriteTone(PIEZO_PIN, 650);
184+
#else
185+
tone(PIEZO_PIN, 650, 300);
186+
#endif
187+
182188
Serial.print("Sending to Adafruit IO -> ");
183189
Serial.println(taskTwo);
184190
cubetask->save(taskTwo, minutes);
@@ -189,8 +195,14 @@ void loop()
189195
Serial.println("Switching to Task 2");
190196
// update the neopixel strip
191197
updatePixels(0, 50, 0);
198+
192199
// play a sound
193-
tone(PIEZO_PIN, 850, 300);
200+
#if defined(ARDUINO_ARCH_ESP32)
201+
ledcWriteTone(PIEZO_PIN, 850);
202+
#else
203+
tone(PIEZO_PIN, 850, 300);
204+
#endif
205+
194206
Serial.print("Sending to Adafruit IO -> ");
195207
Serial.println(taskOne);
196208
cubetask->save(taskOne, minutes);
@@ -199,7 +211,14 @@ void loop()
199211
break;
200212
case 3:
201213
updatePixels(0, 0, 50);
202-
tone(PIEZO_PIN, 950, 300);
214+
215+
// play a sound
216+
#if defined(ARDUINO_ARCH_ESP32)
217+
ledcWriteTone(PIEZO_PIN, 950);
218+
#else
219+
tone(PIEZO_PIN, 950, 300);
220+
#endif
221+
203222
break;
204223
}
205224

0 commit comments

Comments
 (0)