how stop my buzzer

I all,
I success my test outpout buzz .
I have a 3 buttons “low frequance (on)”, “hight frequence(off)”, " stop sound".
I use io.sockets

`
Saisissez io.sockets.on(‘connection’, function (socket) {
socket.on(‘led’, function (data) {
console.log(data);
if(data ==‘stop’){
b.digitalWrite(S_13,b.HIGH);
console.log(‘stop buzz’);
};

if (data == ‘on’){
b.analogWrite(S_13,1/2,3);
//socket.emit(‘ledstatus’, ‘green’);
//socket.broadcast.emit(‘ledupdate’, ‘green’);

}else{
b.analogWrite(S_13,1/2,200);
//socket.emit(‘ledstatus’, ‘red’);
//socket.broadcast.emit(‘ledupdate’, ‘red’);
}

});
});

`

if I clik low buzz and hight buzz is ok ,
but if I want stop buzzer, the buzzer not stop Why ?
console log is display stop buzz when i click stop
console log is display on when i click on
console log is display off when i click off
I try configure S_13 too HIGH but is have the PWM in this poin.
How I can do ?
thank’s for reply how i can stop the buzzer

Mixing digitalWrite and analogWrite could be the problem. Try disabling the buzzer by setting the PWM duty cycle to 0:

if(data ==‘stop’){
b.analogWrite(S_13,0,3);
console.log(‘stop buzz’);
};

thanks michael my buzzer is stop :slight_smile: