I then created a Switch/Case statement that turns on (and off) particular LED's when the appropriate button on the remote is pressed.
Not sure what sensor was in my VCR, but a TSOP4838 should work as well.
This can now be easily used to control motors, lights and other equipment (optically isolated SSR). I've uploaded a video to youtube showing how it all works.
Code and schematics are available at https://docs.google.com/folder/d/0ByRIq5k2wjcSd2FWa3FfQzBib1k/edit
As always comments here and detailed discussion at http://tech.groups.yahoo.com/group/arduinohome/ is encouraged.
We are reading:
Arduino Robotics, by John-David Warren, Josh Adams, & Harald Molle
/*
* IRremote: IRrecvDump - dump details of IR codes with IRrecv
* An IR detector/demodulator must be connected to the input RECV_PIN.
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
* JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
* Heavily modified by Steve Spence, http://arduinotronics.blogspot.com
*/
#include <
int RECV_PIN = 19;
int reversePin = 4; // LED connected to digital pin 13
int forwardPin = 5; // LED connected to digital pin 13
int playPin = 6; // LED connected to digital pin 13
int pausePin = 7; // LED connected to digital pin 13
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
pinMode(reversePin, OUTPUT); // sets the digital pin as output
pinMode(forwardPin, OUTPUT); // sets the digital pin as output
pinMode(playPin, OUTPUT); // sets the digital pin as output
pinMode(pausePin, OUTPUT); // sets the digital pin as output
}
void loop() {
if (irrecv.decode(&results)) {
long int decCode = results.value;
Serial.println(decCode);
switch (results.value) {
case 1431986946:
Serial.println("Forward");
digitalWrite(forwardPin, HIGH); // sets the LED on
break;
case -11780576:
Serial.println("Reverse");
digitalWrite(reversePin, HIGH); // sets the LED on
break;
case -873913272:
Serial.println("Play");
digitalWrite(playPin, HIGH); // sets the LED on
break;
case -1025287420:
Serial.println("Pause");
digitalWrite(pausePin, HIGH); // sets the LED on
break;
case 1791365666:
Serial.println("Stop");
digitalWrite(forwardPin, LOW); // sets the LED off
digitalWrite(reversePin, LOW); // sets the LED off
digitalWrite(playPin, LOW); // sets the LED off
digitalWrite(pausePin, LOW); // sets the LED off
break;
default:
Serial.println("Waiting ...");
}
irrecv.resume(); // Receive the next value
}
}