This library needs work

It was suggested that the Tone32 library was improperly organized.

I was surprised to see so little. Nothing public or private.

This is the whole thing:

#ifndef _TONE32_h
#define _TONE32_h

#define TONE_CHANNEL 15
#include "Arduino.h"
#include "pitches.h"

void tone(uint8_t pin, unsigned int frequency, unsigned long duration = 0, uint8_t channel = TONE_CHANNEL);
void noTone(uint8_t pin, uint8_t channel = TONE_CHANNEL);

What else does it need to be a real library? The declarations took care of the error I was getting from ‘tone’, but they aren’t causing a tone.

It needs the C++ code to implement, not just declare, tone() and noTone()`. All you have thete is a header file.



#include "Tone32.h"

void tone(uint8_t pin, unsigned int frequency, unsigned long duration, uint8_t channel)
    if (ledcRead(channel)) {
        log_e("Tone channel %d is already in use", ledcRead(channel));
    ledcAttachPin(pin, channel);
    ledcWriteTone(channel, frequency);
    if (duration) {
        noTone(pin, channel);

void noTone(uint8_t pin, uint8_t channel)
    ledcWrite(channel, 0);

Wasn’t it the Adafruit library, not tone32, that is “structurally broken”. The one you are/were having problems with?

I see you have found the source code to match the header. Have you tried a simple example? Does it still not work? Could it possibly be the buzzer you are using

That library looks like it hangs up your microcontroller if you supply a duration…

if (duration) {