"* Relay is ON.\n");

Files at this revision

API Documentation at this revision

Comitter:
loveus
Date:
Tue Sep 28 01:18:28 2021 +0000
Commit message:
Relay_Test

Changed in this revision

main.cpp 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 Sep 28 01:18:28 2021 +0000
@@ -0,0 +1,22 @@
+#include "mbed.h"
+
+Serial PC(SERIAL_TX, SERIAL_RX)                                                 // PC와 UART 연결
+
+DigitalOut relayControl(D3);                                                    // 릴레이 제어 핀
+
+int main()
+{
+    while(1) {
+        if(PC.readable() {                                                      // 데이터 수신 여부 확인
+        char ch = PC.gets();
+
+            if(ch == 'O' || ch == 'o') {
+                relayControl = true;
+                PC.printf("* Relay is ON.\n");                                      // ON 메세지 출력
+            } else {
+                relayControl = false;                                               // 릴레이 OFF
+                PC.printf("* Relay is OFF.\n");
+            }
+        }
+    }
+}