utilizzo schield bluethoot HC05 con scheda ST

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Wonderjack996
Date:
Tue May 23 09:36:51 2017 +0000
Commit message:
programma hello world per utilizzo schield bluethoot HC05 con scheda ST

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue May 23 09:36:51 2017 +0000
@@ -0,0 +1,24 @@
+#include "mbed.h"
+
+/*I pin utilizzati per TX e RX sono pin morfo, a livello hardware collegare il pin TX dell HC05 al PA_12 e quello RX a PA_11 ( a livello harware vanno invertiti )*/
+#define TX PA_11
+#define RX PA_12
+
+Serial pc(USBTX, USBRX); //istanzio oggetto per utilizzo monitor seriale
+
+Serial device(TX, RX); //oggetto per gestione seriale bluethoot
+
+int main() {
+    
+    unsigned char rx; 
+    
+    device.baud(9600);
+    pc.baud(9600);
+    
+    while(true){
+        if( device.readable() ) { //funzione simile alla Serial.available() di arduino, solo se il monitor e` attivo permette di utilizzarlo
+            rx = device.getc(); //funzione simile alla Serial.read() di arduino, legge il carattere dal seriale del bluethoot
+            pc.printf("recived: %c \r\n",rx); //stampa a video
+        }
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue May 23 09:36:51 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/4eea097334d6
\ No newline at end of file