Advertisement
microrobotics

KL715 Wireless Tx+Rx 433MHz - Learn

Jul 2nd, 2024
878
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define D0_PIN 16
  2. #define D1_PIN 17
  3. #define D2_PIN 18
  4. #define D3_PIN 19
  5. #define VT_PIN 21  // Optional, for valid transmission detection
  6.  
  7. void setup() {
  8.   Serial.begin(115200);    // Initialize serial communication
  9.  
  10.   // Set D0-D3 pins and VT_PIN as inputs
  11.   pinMode(D0_PIN, INPUT);
  12.   pinMode(D1_PIN, INPUT);
  13.   pinMode(D2_PIN, INPUT);
  14.   pinMode(D3_PIN, INPUT);
  15.   pinMode(VT_PIN, INPUT);
  16. }
  17.  
  18. void loop() {
  19.   if (digitalRead(VT_PIN) == HIGH) { // Check if the VT pin is HIGH (valid transmission detected)
  20.     // Read from each data pin
  21.     int d0_value = digitalRead(D0_PIN);
  22.     int d1_value = digitalRead(D1_PIN);
  23.     int d2_value = digitalRead(D2_PIN);
  24.     int d3_value = digitalRead(D3_PIN);
  25.  
  26.     // Print the values of each data pin
  27.     Serial.print("D0: ");
  28.     Serial.print(d0_value);
  29.     Serial.print(" D1: ");
  30.     Serial.print(d1_value);
  31.     Serial.print(" D2: ");
  32.     Serial.print(d2_value);
  33.     Serial.print(" D3: ");
  34.     Serial.println(d3_value);
  35.   }
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement