Advertisement
microrobotics

Premium 433MHz Remote +RX - EV1527

Dec 5th, 2023
1,428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const int pinD0 = 2; // Connect to D0 on the receiver
  2. const int pinD1 = 3; // Connect to D1 on the receiver
  3. const int pinD2 = 4; // Connect to D2 on the receiver
  4. const int pinD3 = 5; // Connect to D3 on the receiver
  5. const int pinVT = 6; // Connect to VT on the receiver
  6.  
  7. // Debounce variables
  8. unsigned long lastDebounceTime = 0;  // the last time the output pin was toggled
  9. unsigned long debounceDelay = 450;    // the debounce time; increase if the output flickers
  10.  
  11. void setup() {
  12.   Serial.begin(9600);
  13.   pinMode(pinD0, INPUT);
  14.   pinMode(pinD1, INPUT);
  15.   pinMode(pinD2, INPUT);
  16.   pinMode(pinD3, INPUT);
  17.   pinMode(pinVT, INPUT);
  18. }
  19.  
  20. void loop() {
  21.   // Check if there is a valid transmission
  22.   if (digitalRead(pinVT) == HIGH) {
  23.     if ((millis() - lastDebounceTime) > debounceDelay) {
  24.       if (digitalRead(pinD3) == HIGH) {
  25.         Serial.println("Button A pressed");
  26.         lastDebounceTime = millis();
  27.       }
  28.       if (digitalRead(pinD2) == HIGH) {
  29.         Serial.println("Button B pressed");
  30.         lastDebounceTime = millis();
  31.       }
  32.       if (digitalRead(pinD1) == HIGH) {
  33.         Serial.println("Button C pressed");
  34.         lastDebounceTime = millis();
  35.       }
  36.       if (digitalRead(pinD0) == HIGH) {
  37.         Serial.println("Button D pressed");
  38.         lastDebounceTime = millis();
  39.       }
  40.     }
  41.   }
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement