1. 시스템개요 

 

YK04 4채널 리모트콘트롤러 모듈은 송신기에서 A~D버튼 중 하나를 누르면 수신기 D0~D3 단자중 해당 단자에 5V전압이 걸리는 방식이므로 원하는 순간동안만 기기를 ON시킬 수 있지만, 계속 ON상태로 켜 놓았다가 원하는 시간에 OFF시키는 식의 작동을 원할 경우 별도의 프로세서로 이렇게 작동되도록 제어해야 한다.

 

즉, 수신기에서 출력되는 5V 신호를 전원제어를 위한 릴레이에 직접 연결하는 것이 아니고, 이아두이노에서 입력받아  이 신호 구분에 따라 원하는 방식으로 작동되도록 아두이노에서 릴레이를 제어하는 방식으로 제작해야 한다. 

 

 

2. 회로의 구성 

 

3. 릴레이와 아두이노와의 연결 

 

전원제어용 기기를 각각의 릴레이에 연결하고 각각의 릴레이들을 제어하기 위해 아주이노와 다음과 같이 연결한다.

  • VCC to 5V
  • IN1 to A0
  • IN2 to A1
  • IN3 to A2
  • IN4 to A3 
  • GND to GND

 

4. YK04 4채널 리모트콘트롤러 모듈과 아두이노의 연결 

 

 

5. 아두이노 프로그램 

#include <rm4.h>

// Arduino pin connected to the receiver VCC in. Set this high to enable the
// receiver.
static const int kEnablePin = 13;

// Arduino pins connected to the data pins on the receiver.
static const int kData0Pin = 9;
static const int kData1Pin = 10;
static const int kData2Pin = 11;
static const int kData3Pin = 12;
const int relay1 =  14;            
const int relay2 =  15;     
const int relay3 =  16;     
const int relay4 =  17;     

// Create an RM4 object to read the button codes from the remote.
RM4 remote(kData0Pin, kData1Pin, kData2Pin, kData3Pin);

void setup() {
  // Initialize the serial interface.
  Serial.begin(9600);

  // Turn on the receiver.
  pinMode(kEnablePin, OUTPUT);
  digitalWrite(kEnablePin, HIGH);
  pinMode(relay1, OUTPUT);
  pinMode(relay2, OUTPUT);
  pinMode(relay3, OUTPUT);
  pinMode(relay4, OUTPUT);

}

void loop() {
  // Print the button code to the serial interface every 100 ms.
  const int button_code = remote.buttonCode();
   if (button_code == 8) {        
    digitalWrite(relay1, LOW); 
    delay (2000);                     
  } else {                                        
    digitalWrite(relay1, HIGH);     
  }
   if (button_code == 2) {             
    digitalWrite(relay2, LOW);          
    delay (2000);                        
  } else {                                        
    digitalWrite(relay2, HIGH);            
  }
   if (button_code == 1) {                
    digitalWrite(relay3, LOW);              
    delay (2000);                          
  } else {                                        
    digitalWrite(relay3, HIGH);        
  }
   if (button_code == 4) {          
    digitalWrite(relay4, LOW);       
    delay (2000);                 
  } else {                                        
    digitalWrite(relay4, HIGH);    
  }

 // Serial.println(button_code);
  
 // delay(100);
}

여기에 사용된 rm.h 라이브러리는 다음 사이트에서 다운로드 받을 수 있다. 

 

 - github.com/msparks/arduino-rm4   

 

 

위와 같은 제어 시스템을 만드는 것이 번거롭고 단지 필요만 하다면 다음 사이트에서 구매해서 사용하면 된다.

 

 

3.16US $ 60% OFF|GERMA Universal Wireless Remote Control Switch DC 12V 4CH relay Receiver Module With 4 channel RF Remote 433 Mh

Smarter Shopping, Better Living! Aliexpress.com

www.aliexpress.com

 

 

+ Recent posts