This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Connecting a Low Power Buzzer to a GPIO on nrf51 DK (PCA10028)

Hi, I have my nrf51 Dk (PCA10028) on which I want to connect a buzzer or speaker to one of the gpio pins which are not in use. I am confused on the following points:

1. Should the the buzzer be connected to a breadboard with one cable connected to the GND pin and the other to the Gpio pin 3 for example?

2. After connection, how should I define the pin as an output in my program?

3. How is sending a suitable melody (one with a suitable sound ) to the buzzer possible?

4. How can i make sure that this connection does not increase the current consumption of my board?

Any form of help will highly be appreciated

Parents
  • Hi Joseph,

    You can use PWM to generate sounds with a piezo buzzer. You will need to change the frequency and/or duty cycle to make different pitches/tones. To make a simple melody you can play one tone for a fixed number of seconds, then change to a different tone for a fixed number of seconds, and so on, using an app timer to generate the PWM output. For a starting point, take a look at the PWM library example in our SDK here.

    The example uses 2 channels, and drives GPIO pins 17 and 18, which connects to LED1 and LED2 on the DK. For 1 channel PWM use APP_PWM_DEFAULT_CONFIG_1CH instead.

    The increase in power consumption will depend on how much is the current draw from the buzzer and how long do you plan to play the tunes.

    Best Regards,

    Marjeris

Reply
  • Hi Joseph,

    You can use PWM to generate sounds with a piezo buzzer. You will need to change the frequency and/or duty cycle to make different pitches/tones. To make a simple melody you can play one tone for a fixed number of seconds, then change to a different tone for a fixed number of seconds, and so on, using an app timer to generate the PWM output. For a starting point, take a look at the PWM library example in our SDK here.

    The example uses 2 channels, and drives GPIO pins 17 and 18, which connects to LED1 and LED2 on the DK. For 1 channel PWM use APP_PWM_DEFAULT_CONFIG_1CH instead.

    The increase in power consumption will depend on how much is the current draw from the buzzer and how long do you plan to play the tunes.

    Best Regards,

    Marjeris

Children
Related