Before integrating all of the circuits, let’s demonstrate the IR receiver circuit.
Get a Universal Remote and program/test it until you see output from the debugger of the Arduino. It seems to work well with the Universal Remote programmed as a Sony controller.
IR test code:
//
// Universal remote decoder example for Arduino
//
// This simple program reads/decodes the output of a Universal Remote and displays the value.
//
// The IRremote.h library was referenced and downloaded from these locations:
//
// http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html
// http://www.pjrc.com/teensy/td_libs_IRremote.html
//
// I used a universal remote, and programmed it until the software recognized the output.
// It was an Innovage Jumbo Universal Remote and programmed it as Sony 004.
//
// I also used a 3 pin KSM-603LM Optic receiver module where:
//
// pin 1 -> pin 7 of Arduino, pin 2 -> GND, pin 3 Vcc
//
#include
int RECV_PIN = 7; // A nice out of the way pin to connect the receiver to
IRrecv irrecv(RECV_PIN); // Initialize which pin we are receiving on
decode_results results; // Define the variable for storing 'results'
unsigned long oldmillis = 0; // Use my own delay to add a little debouncing
void setup() {
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) { // If there is a result . .
if (millis() - oldmillis > 300) { // Debounce for 300ms
Serial.println(results.value, HEX); // Print the value
oldmillis = millis(); // Reset the delay timer
}
irrecv.resume(); // Receive the next value
}
}
Comments are closed.