Advertisement
microrobotics

HL-A838 Receiver

Mar 31st, 2023
1,347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Receiver
  3.  
  4. Before uploading these sketches to your Arduino boards, please install the "IRremote" library. You can find it in the Arduino Library Manager or on GitHub: https://github.com/z3t0/Arduino-IRremote
  5.  
  6. Once you've installed the library, upload the "Transmitter" code to one Arduino board and the "Receiver" code to another Arduino board. Wire an infrared LED to the IR_LED_PIN (pin 3) on the transmitter board, and connect the HL-A838 module's output pin to the IR_RECEIVER_PIN (pin 11) on the receiver board. Also, connect the module's VCC and GND pins to the appropriate power and ground pins on the Arduino.
  7.  
  8. The transmitter will send an NEC IR code (0x00FFA857) every 3 seconds, and the receiver will print the received signal's value on the Serial Monitor.
  9. */
  10.  
  11. #include <IRremote.h>
  12.  
  13. const int IR_RECEIVER_PIN = 11; // HL-A838 connected to pin 11
  14.  
  15. IRrecv irrecv(IR_RECEIVER_PIN);
  16. decode_results results;
  17.  
  18. void setup() {
  19.   Serial.begin(9600);
  20.   irrecv.enableIRIn(); // Start the receiver
  21. }
  22.  
  23. void loop() {
  24.   if (irrecv.decode(&results)) {
  25.     Serial.print("Received IR signal: ");
  26.     Serial.println(results.value, HEX); // Print the received signal as a hex value
  27.     irrecv.resume(); // Receive the next value
  28.   }
  29.   delay(100);
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement