You are going to have to write a sketch to count the digits (say 4 total) and store them in an array as digit[0], digit[1], digit[2], digit[3]. Therefore you display results would be:
/*
IR remote control (Sony) detection for Arduino, M. Burnette
Binary sketch size: 3,642 bytes (of a 32,256 byte maximum)
☺ 20121230 MRB modifications to adapt to numeric input, avoid dupes,
and to generally "behave" consistently
☺ Used with Electronic Goldmine IR detector MIM 5383H4
http://www.goldmine-elec-products.com/prodinfo.asp?number=G16737
☺ IR detector:
Pin 1: To pin 2 on Arduino
Pin 2: GND
Pin 3: 5V through 33 Ohm resistor
☺ This is based on pmalmsten's code found on the Arduino forum from 2007:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1176098434/0
*/
int irPin = 2; //Sensor pin 1 wired to Arduino's pin 2
int statLED = 13; //Toggle the status LED every time Power is pressed
int start_bit = 2200; //Start bit threshold (Microseconds)
int bin_1 = 1000; //Binary 1 threshold (Microseconds)
int bin_0 = 400; //Binary 0 threshold (Microseconds)
void setup() {
pinMode(statLED, OUTPUT);
digitalWrite(statLED, LOW);
pinMode(irPin, INPUT);
Serial.begin(9600);
Serial.println("IR/Serial Initialized: ");
}
void loop() {
int key = getIRKey(); //Fetch the key
if(key != 0) //Ignore keys that are zero
{
switch(key)
{
case 128: Serial.println("1"); break;
case 129: Serial.println("2"); break;
case 130: Serial.println("3"); break;
case 131: Serial.println("4"); break;
case 132: Serial.println("5"); break;
case 133: Serial.println("6"); break;
case 134: Serial.println("7"); break;
case 135: Serial.println("8"); break;
case 136: Serial.println("9"); break;
case 137: Serial.println("0"); break;
case 144: Serial.println("CH Up"); break;
case 145: Serial.println("CH Down"); break;
case 146: Serial.println("VOL Right"); break;
case 147: Serial.println("VOL Left"); break;
case 148: Serial.println("Mute"); break;
case 165: Serial.println("AV/TV"); break;
case 149: Serial.println("Power");
//This toggles the statLED every time power button is hit
if(digitalRead(statLED) != 1)
digitalWrite(statLED, HIGH);
else
digitalWrite(statLED, LOW);
break;
//default: Serial.println(key); // for inspection of keycode
}
delay(500); // avoid double key logging (adjustable)
}
}
int getIRKey() {
int data[12];
int i;
while(pulseIn(irPin, LOW) < start_bit); //Wait for a start bit
for(i = 0 ; i < 11 ; i++)
data[i] = pulseIn(irPin, LOW); //Start measuring bits, I only want low pulses
for(i = 0 ; i < 11 ; i++) //Parse them
{
if(data[i] > bin_1) //is it a 1?
data[i] = 1;
else if(data[i] > bin_0) //is it a 0?
data[i] = 0;
else
return -1; //Flag the data as invalid; I don't know what it is! Return -1 on invalid data
}
int result = 0;
for(i = 0 ; i < 11 ; i++) //Convert data bits to integer
if(data[i] == 1) result |= (1<<i);
return result; //Return key number
}