Usage Example for Arduino - Wireless Signal Reception and Pairing

Take Arduino as an example. Other main controllers use the same principle, just need to be connected to the corresponding digital port.
The receiving end takes the inching mode as an example, the principles of other modes are the same.

Hardware Preparation

Software Preparation

Pairing

  • Step1. Supply power to the receiver and prepare a 3.3-5V DC power supply, 3.3.5V power supply can be obtained from the expansion board of the main control such as UNO
  • Step2. Dial any one of the DIP switches on the self-generation switch to the top (To avoid misoperation, the D0 terminal will be toggled up at the factory);
  • Step3. Connect a 3.3-5V DC power supply to the upper right corner of the self-generation switch, and the self-generation switch will light up in red at this time;
  • Step4. Press the button on the receiver, the receiver will turn on a blue light at this time, and enter the waiting state for pairing;
  • Step5. Wait for the blue light of the receiver to flash three times and light up again, then the pairing is successful;
  • Step6. Disconnect the 3.3-5V DC power supply from the self-generating switch and wait for 5S to release the stored excess power;
  • Step7. Press the button, the receiver will receive the signal at this time
  • Instruction: The receiver pairing waiting time is 6S, if it does not receive the transmitter's pairing signal within 6S, it will automatically exit the pairing mode.
  • Instruction: If the pairing fails, repeat the first two steps.
  • Instruction: You only need to pair any one of the transmitters D0~D3, and the other three will automatically match.

Connection

Connection

Sample Code

Receiver:

#define Button_D2 2//Arduino
#define Button_D3 3//Arduino
//#define Button_D2 D2 //ESP32
//#define Button_D3 D3 //ESP32

void setup() {
    Serial.begin(115200);
    pinMode(Button_D2, INPUT);
    pinMode(Button_D3, INPUT);
}
void loop() {
  if ( digitalRead(Button_D2) && !digitalRead(Button_D3) ) {
    delay(20);
    if ( digitalRead(Button_D2) && !digitalRead(Button_D3) ){
      Serial.println("Received:D2"); 
      delay(100);
    }
  }
  if ( !digitalRead(Button_D2) && digitalRead(Button_D3) ) {
    delay(20);
    if ( !digitalRead(Button_D2) && digitalRead(Button_D3) ) {
      Serial.println("Received:D3");
      delay(100);
    }
  }  
  if ( digitalRead(Button_D2) && digitalRead(Button_D3) ) {
    delay(20);
    if ( digitalRead(Button_D2) && digitalRead(Button_D3) ) {
      Serial.println("Received:D2&D3");
      delay(100);
    }
  }
}

Expected Results

When only D2 of the module DIP switch is dialed to the top, press the button and the serial monitor will print: "Received: D2".

When only D3 of the module DIP switch is dialed to the top, press the button and the serial monitor will print: "Received: D3".

When D2 and D3 of the module DIP switch are simultaneously dialed to the upper side, press the button, and the serial monitor will print: "Received: D2&D3".

Was this article helpful?

TOP