How to control buzzer frequency

how I can change the frequency of the buzzer

Did you mean the time intervals at which the buzzer should work? If yes, then when we select the Configuration option in the Products field and choose hardware option, there will be a default Data collection rate of 5mins option given in Step 3 which means the buzzer will ring every 5 mins. So in order to change this, we can give desirable values.

I mean how i can control the voice of the buzzer from low to high

Frequency and voice(amplitude) are completely different.
You can use PWM to control the frequency of the buzzer. For this you may use analogWrite(pin,value) where value is in the range 0-255.
Bolt cannot provide true analog signals to handle the amplitude and so you may have to interface a DAC(Digital to Analog Converter) with bolt, if you require to do so.

1 Like

Have A LOOK AT THIS PROGRAM: and then apply whatever, wherever you want:

int speakerOut = 9;//Piezo buzzer's positive terminal is connected to digital pin 9               
byte names[] = {'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C'};  
int tones[] = {1915, 1700, 1519, 1432, 1275, 1136, 1014, 956};
byte melody[] = "2d2a1f2c2d2a2d2c2f2d2a2c2d2a1f2c2d2a2a2g2p8p8p8p";
// count length: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
//                                10                  20                  30
int count = 0;
int count2 = 0;
int count3 = 0;
int MAX_COUNT = 24;
int statePin = LOW;
void siren();

 volatile byte intruder;
 void setup()
   attachInterrupt(0, intruder_detect, RISING);//Initialize the intterrupt pin for the motion sensor (Arduino digital pin 2)
   intruder = 0;
 void loop()
 void intruder_detect()//This function is called whenever an intruder is detected by the arduino
   Serial.println("Intruder detected");
   for(int i=0; i<3; i++)//Play the alarm three times
 void siren()//This function will make the alarm sound using the piezo buzzer
for (count = 0; count < MAX_COUNT; count++) {
      for (count3 = 0; count3 <= (melody[count*2] - 48) * 30; count3++) {
      for (count2=0;count2<8;count2++) {
        if (names[count2] == melody[count*2 + 1]) {       
          analogWrite(speakerOut, 0);
        if (melody[count*2 + 1] == 'p') {
          // make a pause of a certain size
          analogWrite(speakerOut, 0);
1 Like

This code is help full for Different types of buzzer frequency change with Slider Input of HTML using JavaScript.
Using this code you can Generate Different Frequency Depending upon you Slider value that values in between 0 to 255 and OFF button use full for Close buzzer frequency.
onchange() event of slider value set the frequency of buzzer when you press enter.

    <script type="text/javascript" src=""></script>
    setKey('{{ApiKey}}','{{Name}}'); </script>
   <input type="range" min="0" max="255" value="100" onchange="analogWrite(0,this.value); 
  <button onclick="digitalWrite(0, 'LOW');" >OFF</button>

your code was useful . Thank you
but can you please explain what is the funtion of line ‘console.log(‘this.value’)’??

Yes, Sure
it will show you the frequency of buzzer that you can set in you browsers console this link show you how to debug java script program.

1 Like

buzzer is taking some time to implement the can i speed this up?