Tuesday, November 27, 2012

XBee playing "The Imperial March" using a buzzer


In this sample we show how to play a tune using a buzzer and the PWM interface of the Digi Programmable XBee module.

Here a video with the result:
Direct Link to the Video:  LINK


If you can try the sample, here is the source code: LINK

For this sample we are using the PWM API that provides the SDK delivered with the Digi Programmable XBee:
Pulse-Width Modulation (PWM)
Functions
int
pwm_config (xpin_t pin, bool_t enable, uint32_t ton, uint32_t period)
Function that configures the settings of the Pulse-Width-Modulation module.
int
pwm_enable (xpin_t pin, bool_t enable)
Function that enables/disables the Pulse-Width-Modulation.
Function that returns the current period for the Pulse-Width-Modulation component.
Function that returns the current positive semiperiod for the Pulse-Width-Modulation component.
Function that changes the positive pulse-width of the Pulse-Width-Modulation component.



Thanks to Sebas for the video and the source code!