![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Driver buzzer on LinkNode to play music!
The LinkNode, also called Mbed BLE Sensors tag, which is a bluetooth 4.0 BLE sensor development board and it is powered by Mbed. It integrates powerful devices, such as NRF51822, LIS3DH ,BMP180, buzzer, and dual-color LED. It also embeds an mbed compatible programmer to make program and download application very convenient.
The mbed BLE sensors tag is consisted of two modules: one is a bluetooth 4.0 BLE sensors tag powered by NRF51822 which is a Bluetooth Low Energy & 2.4GHz Wireless SOC. This mbed BLE sensor tag is mbed-enabled device which simplifies and speeds up the creation and deployment of bluetooth devices based on ARM micro-controllers. There is an mbed library supporting BLE sensors tag which provides the C/C++ software platform and libraries, and can speed up your BLE application development.
The other one works as a programmer like Jlink, but it is compatible with ARM’s mbed. It greatly simplifies the programming process. You just copy the compiled hex file to an emulated disk, which is recognized by PC when you plug this programmer into the PC and the programmer will automatically download the program into BLE SENSORS TAG without any other setting.
Pin map of LinkNode
main.cpp@0:878f20e5795a, 2016-04-14 (annotated)
- Committer:
- youkee
- Date:
- Thu Apr 14 01:54:38 2016 +0000
- Revision:
- 0:878f20e5795a
Driver Buzzer on LinkNode to play music!
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
youkee | 0:878f20e5795a | 1 | #include "mbed.h" |
youkee | 0:878f20e5795a | 2 | PwmOut buzzer(p22); |
youkee | 0:878f20e5795a | 3 | //频率数组 |
youkee | 0:878f20e5795a | 4 | float frequency[]={659,554,659,554,440,494,554,587,494,659,554,440}; |
youkee | 0:878f20e5795a | 5 | float beat[]={1,1,1,1,1,0.5,0.5,1,1,1,1,2}; //节拍数组 |
youkee | 0:878f20e5795a | 6 | int main() { |
youkee | 0:878f20e5795a | 7 | while (1) { |
youkee | 0:878f20e5795a | 8 | for (int i=0;i<=11;i++) { |
youkee | 0:878f20e5795a | 9 | buzzer.period(1/(2*frequency[i])); // 设置PWM周期 |
youkee | 0:878f20e5795a | 10 | buzzer=0.5; // 设置占空比 |
youkee | 0:878f20e5795a | 11 | wait(0.4*beat[i]); // 保持节拍周期 |
youkee | 0:878f20e5795a | 12 | } |
youkee | 0:878f20e5795a | 13 | } |
youkee | 0:878f20e5795a | 14 | } |