Professional Documents
Culture Documents
106 4 2
106 4 2
void setup() {
// put your setup code here, to run once:
pinMode(13,OUTPUT);
digitalWrite(13,LOW); //수신모드
pinMode(4,OUTPUT);//LED
mySerial.begin(9600);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
if(mySerial.available()){
//소프트웨어 시리얼로 수신된 값이 존재한다면~
//RS485 모듈로부터 입력받는 값이 존재한다면~
int id = mySerial.read();
int recv = mySerial.read();
if(full == false){
buff[0] = id;
buff[1] = recv;
full = true;
}else{
full = false;
recv = id - '0';
id = buff[0] - '0';
Serial.println(id);
Serial.println(recv);
Serial.println("----------");