BRANDON GARCIA
/
Bluetooth_LED_Test
Turn ON & OFF an LED via Bluetooth using the HC06 module
main.cpp
- Committer:
- brandongarcia
- Date:
- 2020-12-17
- Revision:
- 0:3802a6cf8d31
File content as of revision 0:3802a6cf8d31:
#include "mbed.h" Serial bluetooth(PB_6, PB_3);//Pins used for communicating DigitalOut led(LED1);//LED1 is pin PA_5 or D13 / LED integrated in nucleoboard int main() { lcd.cls(); bluetooth.baud(9600);//Default rate is 9600 bps bluetooth.printf("If '1' is sent then turn on LED1 , if '0' turn it off\n"); while(1) { char c = bluetooth.getc(); // To read the data sent thorugh the bluetooth module if (c == '0') {// If value equals '0' led = 0; // Turn OFF LED1 } if (c == '1') {// If value equals '1' led = 1; // Turn ON LED1 } } }