Skip to content

Commit 36bc730

Browse files
committed
pull BUZZER pin low when not use
1 parent 27f0788 commit 36bc730

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

libraries/BLEAdafruitService/src/services/BLEAdafruitTone.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ err_t BLEAdafruitTone::begin(int pin)
6060
_tone.setWriteCallback(tone_write_cb, true);
6161
VERIFY_STATUS( _tone.begin() );
6262

63+
pinMode(_pin, OUTPUT);
64+
digitalWrite(_pin, LOW);
65+
6366
return ERROR_NONE;
6467
}
6568

@@ -79,11 +82,14 @@ void BLEAdafruitTone::tone_write_cb(uint16_t conn_hdl, BLECharacteristic* chr, u
7982
memcpy(&tone_data, data, len);
8083

8184
// frequency = 0 means no tone
85+
int pin = svc._pin;
86+
8287
if (tone_data.freq == 0)
8388
{
84-
noTone(svc._pin);
89+
noTone(pin);
90+
digitalWrite(pin, LOW);
8591
}else
8692
{
87-
tone(svc._pin, tone_data.freq, tone_data.duration);
93+
tone(pin, tone_data.freq, tone_data.duration);
8894
}
8995
}

libraries/Bluefruit52Lib/examples/Peripheral/bluefruit_playground/bluefruit_playground.ino

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,6 @@ void setup()
179179
pinMode(PIN_BUTTON1, INPUT_PULLUP);
180180
pinMode(PIN_BUTTON2, INPUT_PULLUP);
181181

182-
// Buzzer Speaker
183-
pinMode(PIN_BUZZER, OUTPUT);
184-
185182
apds9960.begin();
186183
apds9960.enableColor(true);
187184

0 commit comments

Comments
 (0)