Advertisement
microrobotics

HL-A838 Transmitter

Mar 31st, 2023
1,306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Transmitter
  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.  
  12. #include <IRremote.h>
  13.  
  14. const int IR_LED_PIN = 3; // IR LED connected to pin 3
  15.  
  16. IRsend irsend(IR_LED_PIN);
  17.  
  18. void setup() {
  19.   Serial.begin(9600);
  20.   pinMode(IR_LED_PIN, OUTPUT);
  21. }
  22.  
  23. void loop() {
  24.   Serial.println("Sending IR signal...");
  25.   irsend.sendNEC(0x00FFA857, 32); // Send a test NEC code (0x00FFA857)
  26.   delay(3000); // Wait 3 seconds between signals
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement