//int playing = 0; //void tone(byte pin, double freq) { //ledcSetup(0, freq, 8); // setup beeper //ledcAttachPin(pin, 0); // attach beeper //ledcWriteTone(0, freq); // play tone //playing = pin; // store pin //} int pin = 25; int freq = 1047; int channel = 1; void setup() { Serial.begin(115200); //pinMode(pin, OUTPUT); ledcSetup(channel, freq, 8); // setup beeper ledcAttachPin(pin, channel); // attach beeper //ledcWriteTone(channel,freq); ledcWrite(channel, 128); // play tone Serial.println("played tone"); } void loop() { // no need to repeat the melody. }