Arduino Full Stack
search
⌘Ctrlk
Arduino Full Stack
  • Preface
  • Part 1 - Introduction
  • Chapter 1. Getting Started with Arduino
  • Chapter 2. Programming Grammar
  • Part 2 - Sensors
  • Chapter 3. LED Sensors
  • Chapter 4. Infrared Sensors
    • 4.1 Infrared Emitter and Receiver
    • 4.2 Laser Emitter
    • 4.3 Infrared Remote Control
    • 4.4 IR Obstacle Avoidance
    • 4.5 IR Line Tracking
  • Chapter 5. Audio Sensors
  • Chapter 6. Magnetic Sensors
  • Chapter 7. Touch Sensors
  • Chapter 8. Thermist Sensors
  • Chapter 9. Switches
  • Chapter 10. Other Sensors
  • Chapter 11. More Discussions on Sensors
  • Part 3 - Motors
  • Chapter 12. Motors
  • Part 4 - Display
  • Chapter 13. Display
  • Part 5 - Communication
  • Chapter 14. Communication
  • Part 6 - Arduino Based Mini Automated Vehicle
  • Chapter 15. Assemble a Mini Automated Vehicle
  • Chapter 16. Remote Control
gitbookPowered by GitBook
block-quoteOn this pagechevron-down
  1. Chapter 4. Infrared Sensors

4.1 Infrared Emitter and Receiver

hashtag
Hardware Wiring

Infrared Emitter and Receiver

hashtag
Sketch

The code can be found at Examples_Arduino - sensor-kit-for-arduino - _005_IRRemote_Emit - _005_IRRemote_Emit.inoarrow-up-right and Examples_Arduino - sensor-kit-for-arduino - _005_IRRemote_Receive - _005_IRRemote_Receive.inoarrow-up-right .

hashtag
Emit

hashtag
Receive

PreviousChapter 4. Infrared Sensorschevron-leftNext4.2 Laser Emitterchevron-right

Last updated 7 years ago

  • Hardware Wiring
  • Sketch
  • Emit
  • Receive
#include <IRremote.h>
IRsend irsend;
void setup()
{
  Serial.begin(9600);
}
void loop() {
  for (int i = 0; i < 50; i++) {
    irsend.sendSony(0xa90, 12); // Sony TV power code
    delay(40);
  }
}
#include <IRremote.h>
int RECV_PIN = 11; //define input pin on Arduino
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}
void loop() {
  irrecv.decode(&results);
  Serial.println(results.value, HEX);
if (irrecv.decode(&results)) {
  Serial.println(results.value, HEX);
  irrecv.resume(); // Receive the next value
  }
}