// Read Sony SIRC 12 Infrared Remote Protocol
// Arduino code for 3 pin 40kHZ IR receiver chip
// initialise
void setup()
{
pinMode(15,INPUT); // set pin ?? as input
Serial.begin(9600); // 9600 baud 8,n,1
}
// keep looping to get button press information forever
void loop()
{
int v=0; // initialise v (12 bit address/command store)
int a=pulseIn(15,LOW); // expecting start bit of 2400uS low
if(a>2000) // only process message if start bit is longer than 2000uS
{
for(int i=0;i<12;i++) // SIRC 12 protocol is 12 data bits (after start bit)
{
if(pulseIn(15,LOW)>1000) // doubt is here - 600uS low for zero bit - so do nothing
{ // 1200us low for 'on'e bit, so change a single bit to a 1
v=v+(1<<i); // change bit 'i' to a one if 1200uS low
}
}
Serial.println(v); // send the result to serial port
delay(500); // stop listening for a while (maybe to ignore the repeat messages that SOny usually send)
}
}