TINF_Serial_Echo_7_5_2018

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
martwerl
Date:
Thu Nov 15 18:25:02 2018 +0000
Commit message:
TINF_Serial_Echo_7_5_2018

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	Thu Nov 15 18:25:02 2018 +0000
@@ -0,0 +1,83 @@
+#include "mbed.h"
+ 
+Serial pc(USBTX, USBRX); // tx, rx
+DigitalOut led1(LED1);
+
+// Globale Variable
+char in[100];
+bool flag = false;
+//string eingabe;
+/*
+char in;
+bool flag = false;
+char instring[128];
+int counter = 0;
+
+float brightness = 0.0;
+
+void receive()
+{
+    while (pc.readable()) {
+
+
+        instring[counter] = pc.getc();
+        counter++;
+    }
+    flag = true;
+
+}
+
+int main()
+{
+    pc.attach(&receive);
+
+    while(1) {
+
+        if (flag) {
+            //pc.putc(in);
+            //strcpy(instring, "0");
+            instring[counter+1]=0;
+            pc.puts(instring);
+            flag = false;
+            counter=0;
+        }
+        
+        led2 = !led2;
+        wait(0.2);
+
+    }
+}
+
+
+
+*/
+
+void receive()  //  callback
+{
+//        pc.putc(pc.getc()); // echo input back to terminal
+    while (pc.readable())
+    {
+        in[100] = pc.getc();//Todo: char in ein Feld ablegen und aus diesem einen String machen
+       // eingabe = in[100];
+    }
+        flag = true;
+}
+
+ 
+int main() {
+    pc.attach(&receive);
+
+    pc.printf("Hello World!\n\r");//HTerm: Baudrate 9600, Port aussuchen, oben Newline at "CR+LF". Bei Drücken auf Reset erschkeint Hello World
+    while(1) 
+    {
+        if(flag)
+        {
+            //pc.putc(in);  
+                            //Todo: mit puts den String ausgeben
+            pc.puts(&in[100]);
+            flag = false;  
+        }
+            led1 = !led1;
+            wait(0.2);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 15 18:25:02 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/5aab5a7997ee
\ No newline at end of file