셀프 테스트 할때는 9번 TX Pin핀을 0번 HW RX PiN에 연결하여 셀프 테스트 합니다.
#include <SoftwareSerial.h>
#include "My_Arduino_GPIO_Lib_V1_6.h"
#define Arduino 1
#define HW_Uart_mode 2
#include "My_MCU_Printf_Lib_V2_2.h"
// 객체선언
#define Rx_Pin 8
#define Tx_Pin 9
SoftwareSerial My_Port(Rx_Pin, Tx_Pin);
char rx_buf;
void setup() {
// put your setup code here, to run once:
My_Port.begin(9600);
Serial.begin(9600);
pinMode(Rx_Pin, INPUT);
pinMode(Tx_Pin, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
// SW uart TX == 1번
My_Port.println("Song"); // 1번
/*
// SW UART RX == 폴링방식 수신처리
if(My_Port.available() > 0) // 2번
{
rx_buf = My_Port.read();
Serial.println("RX Data = ");
Serial.write(rx_buf); // 3번
}
*/
if(Serial.available() > 0) // 2번
{
rx_buf = Serial.read();
Serial.println("song\r\n");
}
delay(1000);
}