Usage Example for Arduino-Controller-Controlled Signal Transmission

  • This sample is mainly used for demonstration: power the transmitter through the controller, and control the transmitter to transmit signals

  • Take Arduino as an example, the other main controllers use the same principle, only need to connect to the corresponding digital port.

  • Take inching mode in the receiver as an example, the principles of other modes are the same.

Hardware Preparation

Software Preparation

Connection

The transmitting end:

Receiving end:

Sample code

The transmitting end:

#define Button_D2 2//Arduino
//#define Button_D2 D2 //ESP32

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  digitalWrite(Button_D2, HIGH);
  delay(1000);
  digitalWrite(Button_D2, LOW);
  delay(1000);
}
}

Receiving end:

#define Button_D2 2//Arduino
//#define Button_D2 D2 //ESP32

void setup() {
    Serial.begin(115200);
    pinMode(Button_D2, INPUT);
}
void loop() {
    if (digitalRead(Button_D2)) {
        Serial.println("Pressed:D2");
        delay(1000);
    }
}

Result

The transmitter G-D2 sends out signals every 1 second, and the receiver D2 receives signals every 1 second.

Was this article helpful?

TOP