Anoney Potter / Mbed 2 deprecated SerialEvent

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
anoney180133
Date:
Sat Feb 08 01:48:59 2020 +0000
Commit message:
SerialEvent;

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
diff -r 000000000000 -r 946b1944fab1 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Feb 08 01:48:59 2020 +0000
@@ -0,0 +1,34 @@
+#include "mbed.h"
+
+DigitalOut led1(LED1);
+
+/* No need Serial to UART just usb debugger. */
+Serial UART(SERIAL_TX, SERIAL_RX);
+char UART_char;
+void SerialEvent()
+{
+    char input_char = UART.getc();
+    printf("%c \n\r",input_char);
+    if(input_char == '1')
+    {
+        printf("Press '1' turn on \r\n");
+        led1.write(1);
+    }
+    else if(input_char == '0')
+    {
+        printf("Press '0' turn off \r\n");
+        led1.write(0);
+    }
+}
+
+int main()
+{
+    UART.baud(115200);
+    UART.attach(&SerialEvent,Serial::RxIrq);
+    printf("Start\r\nTurn ON press '1' Turn OFF press '0'\r\n");
+    while(true) 
+    {
+        printf("Wait Interrupt\r\n");
+        wait(1000);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 946b1944fab1 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Feb 08 01:48:59 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file