arduino / arduino/ArduinoCore-avr

Tone (inverted logic)

Open
#489 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C
Stars
1.5k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

(This is not an bug but an improvement request).

Tone works fine with passive buzzers that beep when the pin is HIGH : https://github.com/arduino/ArduinoCore-avr/blob/master/cores/arduino/Tone.cpp#L494

I have a passive buzzers that has inverted logic. It is driven with a PNP transistor. I control the buzzer with a digital pin. The buzzer beeps when the pin is LOW.
The work around to keep using tone() with such buzzers is to call ```digitalWrite(buzzerPin, HIGH)``` instead of ```noTone()```.
The downside is that "click" after the tone has played : https://www.youtube.com/watch?v=zVIw2HHbOZw

Is there a way to inverse this whole logic in Tone.cpp ?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in cores/arduino/Tone.cpp, especially the linked logic around line 494, and trace how tone() and noTone() drive the pin. Define how inverted-logic passive buzzers should be supported without the reported post-tone click, then verify that the existing active-high behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.