Eugen Frštek / Uart

Files at this revision

API Documentation at this revision

Comitter:
efrstek
Date:
Sat Feb 08 16:14:23 2020 +0000
Parent:
0:cc0cf84c7541
Commit message:
uart

Changed in this revision

uart.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uart.h	Sat Feb 08 16:14:23 2020 +0000
@@ -0,0 +1,28 @@
+#include "mbed.h"
+Serial app(PA_2,PA_3);
+short ping;
+int t;
+void start()
+{
+    char pin;
+    pin=app.getc();
+    ping=pin;
+
+}
+int main()
+{
+    app.baud(9600);
+    app.attach(&start, Serial::RxIrq);
+    while(1) {
+        pc.printf("Primljeni podatak: %d\n",ping);
+        if(ping==1) {
+            //start program
+            t=1;
+        }
+        if(ping==0) {
+            //stop program
+            t=0;
+        }
+        wait(1);
+    }
+}
\ No newline at end of file