gmarty2000-ARDUINO / arduino-BUZZER

GNU General Public License v3.0
11 stars 1 forks source link

error: 'tone' / 'notone' was not declared in this scope #1

Open Truebsal opened 5 years ago

Truebsal commented 5 years ago

error: 'tone' / 'notone' was not declared in this scope for esp32

slaesh commented 4 years ago
#define TONE_LEDC_CHANNEL (0)

void tone(uint8_t pin, unsigned int frequency)
{
    if (ledcRead(TONE_LEDC_CHANNEL))
    {
        Serial.printf("Tone channel %d is already in use\r\n", ledcRead(TONE_LEDC_CHANNEL));
        return;
    }

    ledcAttachPin(pin, TONE_LEDC_CHANNEL);
    ledcWriteTone(TONE_LEDC_CHANNEL, frequency);
}

void noTone(uint8_t pin)
{
    ledcDetachPin(pin);
    ledcWrite(TONE_LEDC_CHANNEL, 0);
}