Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

Infrared Communication

Infrared communication is a key technology used in various applications, such as remote controls, wireless data transfer, and proximity sensors. It allows for wireless communication between devices using infrared light. Understanding and implementing infrared communication is essential for engineers and hobbyists working with Arduino and other microcontrollers.

Project: In this project, we will create a simple infrared communication system using Arduino. The objective is to transmit and receive data wirelessly between two Arduino boards using infrared light. The system will consist of a transmitter and a receiver, and we will explore different functionalities and challenges associated with infrared communication.

List of Components:

  • Arduino Uno (2x)
  • Infrared LED (1x)
  • Infrared Receiver Module (1x)
  • Jumper Wires

You can purchase the components from the following links:

  • Arduino Uno: [Link]
  • Infrared LED: [Link]
  • Infrared Receiver Module: [Link]
  • Jumper Wires: [Link]

Examples:

  1. Transmitting Data:
    
    #include <IRremote.h>

define IR_LED_PIN 9

IRsend irSender;

void setup() { Serial.begin(9600); irSender.begin(); }

void loop() { irSender.sendNEC(0x00FF00, 32); // Transmit a sample NEC code delay(1000); }

Explanation:
- We include the IRremote library for Arduino, which provides functions for infrared communication.
- We define the pin to which the infrared LED is connected.
- In the setup function, we initialize the serial communication and the infrared sender.
- In the loop function, we use the sendNEC function to transmit a sample NEC code (0x00FF00) with a length of 32 bits.
- We add a delay of 1 second between transmissions.

2. Receiving Data:
```arduino
#include <IRremote.h>

#define IR_RECEIVER_PIN 11

IRrecv irReceiver(IR_RECEIVER_PIN);

decode_results results;

void setup() {
  Serial.begin(9600);
  irReceiver.enableIRIn();
}

void loop() {
  if (irReceiver.decode(&results)) {
    Serial.println(results.value, HEX); // Print the received code in hexadecimal format
    irReceiver.resume();
  }
}

Explanation:

  • We include the IRremote library for Arduino.
  • We define the pin to which the infrared receiver module is connected.
  • In the setup function, we initialize the serial communication and enable the infrared receiver.
  • In the loop function, we check if a code has been received using the decode function.
  • If a code is received, we print it in hexadecimal format using the Serial.println function and resume the receiver.

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.