This is a very basic bluetooth program which sends data (a number in this case) through bluetooth module to a PC or smart phone (simply any device which has bluetooth connectivity) and increments the number every 500 ms and writes it to the screen with the regular printf function.

Dependencies:   mbed

Committer:
BaserK
Date:
Thu Jul 09 07:41:52 2015 +0000
Revision:
1:4e5b38982e90
Parent:
0:818577562aa4
Child:
2:14757fbab275
Comments are updated, the same code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
BaserK 0:818577562aa4 1 /* Bluetooth(HC-06) example on LPC1768
BaserK 0:818577562aa4 2 *
BaserK 0:818577562aa4 3 * @author: Baser Kandehir
BaserK 0:818577562aa4 4 * @date: July 9, 2015
BaserK 0:818577562aa4 5 * @license: Use this code however you'd like
BaserK 0:818577562aa4 6 *
BaserK 0:818577562aa4 7 * @description of the program:
BaserK 0:818577562aa4 8 *
BaserK 1:4e5b38982e90 9 * This is a very basic bluetooth program which sends data (a number in this case)
BaserK 1:4e5b38982e90 10 * through bluetooth module to a PC or smart phone (simply any device which has
BaserK 1:4e5b38982e90 11 * bluetooth connectivity) and increments the number every 500 ms and writes it
BaserK 1:4e5b38982e90 12 * to the screen with the regular printf function.
BaserK 0:818577562aa4 13 *
BaserK 0:818577562aa4 14 * @connections:
BaserK 0:818577562aa4 15 *--------------------------------------------------------------
BaserK 0:818577562aa4 16 * |LPC1768| |Peripherals|
BaserK 0:818577562aa4 17 * Pin 13 --------> (TX) RX pin of the Bluetooth module
BaserK 0:818577562aa4 18 * Pin 14 --------> (RX) TX pin of the Bluetooth module
BaserK 0:818577562aa4 19 * GND -----------> GND of the Bluetooth module
BaserK 0:818577562aa4 20 * VOUT (3.3 V) --> VCC of the Bluetooth module
BaserK 0:818577562aa4 21 *---------------------------------------------------------------
BaserK 0:818577562aa4 22 *
BaserK 0:818577562aa4 23 */
BaserK 0:818577562aa4 24
BaserK 0:818577562aa4 25 #include "mbed.h"
BaserK 0:818577562aa4 26
BaserK 0:818577562aa4 27 Serial bluetooth(p13,p14); // p13: TX, p14: RX (LPC1768)
BaserK 0:818577562aa4 28 int i=0;
BaserK 0:818577562aa4 29
BaserK 0:818577562aa4 30 int main()
BaserK 0:818577562aa4 31 {
BaserK 0:818577562aa4 32 bluetooth.baud(9600);
BaserK 0:818577562aa4 33 bluetooth.printf("Hello world... \r\n");
BaserK 0:818577562aa4 34 while(1)
BaserK 0:818577562aa4 35 {
BaserK 0:818577562aa4 36 i++;
BaserK 0:818577562aa4 37 bluetooth.printf("Value of the i is: %d \r\n",i);
BaserK 0:818577562aa4 38 wait(0.5);
BaserK 0:818577562aa4 39 }
BaserK 0:818577562aa4 40 }