Smart Home Automation Forum
[arduino source code for KC868-Uair-3] Let buzzer play tone - Printable Version

+- Smart Home Automation Forum (https://www.kincony.com/forum)
+-- Forum: Technical Support (https://www.kincony.com/forum/forumdisplay.php?fid=20)
+--- Forum: KC868-Uair (https://www.kincony.com/forum/forumdisplay.php?fid=31)
+--- Thread: [arduino source code for KC868-Uair-3] Let buzzer play tone (/showthread.php?tid=1563)



[arduino source code for KC868-Uair-3] Let buzzer play tone - admin - 12-30-2021

// define Buzzer GPIO
const int TONE_OUTPUT_PIN = 26;

const int TONE_PWM_CHANNEL = 0;

void setup() {
  ledcAttachPin(TONE_OUTPUT_PIN, TONE_PWM_CHANNEL);
}

void loop() {
  // Plays the middle C scale
  ledcWriteNote(TONE_PWM_CHANNEL, NOTE_C, 4);
  delay(500);
  ledcWriteNote(TONE_PWM_CHANNEL, NOTE_D, 4);
  delay(500);
  ledcWriteNote(TONE_PWM_CHANNEL, NOTE_E, 4);
  delay(500);
  ledcWriteNote(TONE_PWM_CHANNEL, NOTE_F, 4);
  delay(500);
  ledcWriteNote(TONE_PWM_CHANNEL, NOTE_G, 4);
  delay(500);
  ledcWriteNote(TONE_PWM_CHANNEL, NOTE_A, 4);
  delay(500);
  ledcWriteNote(TONE_PWM_CHANNEL, NOTE_B, 4);
  delay(500);
  ledcWriteNote(TONE_PWM_CHANNEL, NOTE_C, 5);
  delay(500);
}

download arduino IDE source code file: 

.zip   play tone.zip (Size: 369 bytes / Downloads: 301)


RE: [arduino source code for KC868-Uair-3] Let buzzer play tone - attilhacks - 12-29-2023

Hello, this is very nice, is there a way to do it also with Esphome?
thanks


RE: [arduino source code for KC868-Uair-3] Let buzzer play tone - admin - 12-29-2023

i have not tried. But use esphome lambda can do that.