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.
main.cpp@2:14757fbab275, 2015-07-21 (annotated)
- Committer:
- BaserK
- Date:
- Tue Jul 21 07:51:02 2015 +0000
- Revision:
- 2:14757fbab275
- Parent:
- 1:4e5b38982e90
MIT license added
Who changed what in which revision?
User | Revision | Line number | New 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 | 2:14757fbab275 | 5 | * @license: MIT license |
BaserK | 2:14757fbab275 | 6 | * |
BaserK | 2:14757fbab275 | 7 | * Copyright (c) 2015, Baser Kandehir, baser.kandehir@ieee.metu.edu.tr |
BaserK | 2:14757fbab275 | 8 | * |
BaserK | 2:14757fbab275 | 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
BaserK | 2:14757fbab275 | 10 | * of this software and associated documentation files (the "Software"), to deal |
BaserK | 2:14757fbab275 | 11 | * in the Software without restriction, including without limitation the rights |
BaserK | 2:14757fbab275 | 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
BaserK | 2:14757fbab275 | 13 | * copies of the Software, and to permit persons to whom the Software is |
BaserK | 2:14757fbab275 | 14 | * furnished to do so, subject to the following conditions: |
BaserK | 2:14757fbab275 | 15 | * |
BaserK | 2:14757fbab275 | 16 | * The above copyright notice and this permission notice shall be included in |
BaserK | 2:14757fbab275 | 17 | * all copies or substantial portions of the Software. |
BaserK | 2:14757fbab275 | 18 | * |
BaserK | 2:14757fbab275 | 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
BaserK | 2:14757fbab275 | 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
BaserK | 2:14757fbab275 | 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
BaserK | 2:14757fbab275 | 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
BaserK | 2:14757fbab275 | 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
BaserK | 2:14757fbab275 | 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
BaserK | 2:14757fbab275 | 25 | * THE SOFTWARE. |
BaserK | 2:14757fbab275 | 26 | * |
BaserK | 0:818577562aa4 | 27 | * @description of the program: |
BaserK | 0:818577562aa4 | 28 | * |
BaserK | 1:4e5b38982e90 | 29 | * This is a very basic bluetooth program which sends data (a number in this case) |
BaserK | 1:4e5b38982e90 | 30 | * through bluetooth module to a PC or smart phone (simply any device which has |
BaserK | 1:4e5b38982e90 | 31 | * bluetooth connectivity) and increments the number every 500 ms and writes it |
BaserK | 1:4e5b38982e90 | 32 | * to the screen with the regular printf function. |
BaserK | 0:818577562aa4 | 33 | * |
BaserK | 0:818577562aa4 | 34 | * @connections: |
BaserK | 0:818577562aa4 | 35 | *-------------------------------------------------------------- |
BaserK | 0:818577562aa4 | 36 | * |LPC1768| |Peripherals| |
BaserK | 0:818577562aa4 | 37 | * Pin 13 --------> (TX) RX pin of the Bluetooth module |
BaserK | 0:818577562aa4 | 38 | * Pin 14 --------> (RX) TX pin of the Bluetooth module |
BaserK | 0:818577562aa4 | 39 | * GND -----------> GND of the Bluetooth module |
BaserK | 0:818577562aa4 | 40 | * VOUT (3.3 V) --> VCC of the Bluetooth module |
BaserK | 0:818577562aa4 | 41 | *--------------------------------------------------------------- |
BaserK | 0:818577562aa4 | 42 | * |
BaserK | 0:818577562aa4 | 43 | */ |
BaserK | 0:818577562aa4 | 44 | |
BaserK | 0:818577562aa4 | 45 | #include "mbed.h" |
BaserK | 0:818577562aa4 | 46 | |
BaserK | 0:818577562aa4 | 47 | Serial bluetooth(p13,p14); // p13: TX, p14: RX (LPC1768) |
BaserK | 0:818577562aa4 | 48 | int i=0; |
BaserK | 0:818577562aa4 | 49 | |
BaserK | 0:818577562aa4 | 50 | int main() |
BaserK | 0:818577562aa4 | 51 | { |
BaserK | 0:818577562aa4 | 52 | bluetooth.baud(9600); |
BaserK | 0:818577562aa4 | 53 | bluetooth.printf("Hello world... \r\n"); |
BaserK | 0:818577562aa4 | 54 | while(1) |
BaserK | 0:818577562aa4 | 55 | { |
BaserK | 0:818577562aa4 | 56 | i++; |
BaserK | 0:818577562aa4 | 57 | bluetooth.printf("Value of the i is: %d \r\n",i); |
BaserK | 0:818577562aa4 | 58 | wait(0.5); |
BaserK | 0:818577562aa4 | 59 | } |
BaserK | 0:818577562aa4 | 60 | } |