ToneExample.ino 366 B

12345678910111213141516171819202122232425
  1. /*
  2. */
  3. #include <ESP32Servo.h>
  4. int pin = 2;
  5. void setup() {
  6. // Allow allocation of all timers
  7. ESP32PWM::allocateTimer(0);
  8. ESP32PWM::allocateTimer(1);
  9. ESP32PWM::allocateTimer(2);
  10. ESP32PWM::allocateTimer(3);
  11. Serial.begin(115200);
  12. }
  13. void loop() {
  14. tone(pin, 4186, // C
  15. 500); // half a second
  16. tone(pin, 5274, // E
  17. 500); // half a second
  18. delay(500);
  19. }