Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:d77732c19d1e, committed 2021-09-28
- 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");
+ }
+ }
+ }
+}