This is an old revision of the document!


/********************************************************
*  Code to access the raw data coming from teh I2C thermo
*  pile array and dispay it on the console.
*  By: Jonathan Mash
*  Date: Feb. 2009
*  Based on work by: Jon McPhalen (www.jonmcphalen.com)
*********************************************************/
 
int irPin = 2;
bool incoming_ir = false;
 
void setup()
{
  pinMode(irPin, INPUT);
  Serial.begin(9600);
  delay(25);
  attachInterrupt(0, IRISR, FALLING);
}
 
void IRISR()
{
    incoming_ir = true;
}
 
void loop()
{
  int key;
 
  if(incoming_ir == true)
  {
    key = getSircs();
 
    if(key == 0x1D01)
      Serial.println("POWER");
    else if(key == 0x701)
      Serial.println("Volume UP");
    else if(key == 0x901)
      Serial.println("Volume DN");
    else
      Serial.println("Unknown Command");
  }
 
  Serial.println(analogRead(0));
 
  delay(50);
}
 
int getSircs() {
  int duration;
  int irCode;
  int mask;
 
  incoming_ir = false;
  // wait for start bit
  do {
    duration = pulseIn(irPin, HIGH);
  } while (duration < 2000);
 
  // get 12-bit SIRCS code
  irCode = 0;						// clear ir code
  mask = 1;						// set mask to bit 0
  for (int idx = 0; idx < 16; idx++) {		        // get all 12 bits
    duration = pulseIn(irPin, HIGH);		        // measure the bit pulse
    if (duration >= 600)				// 1 bit?
	irCode |= mask;					// yes, update ir code
    mask <<= 1;						// shift mask to next bit
  }
  return irCode;
}
irdecode.1236145131.txt.gz · Last modified: by jonmash
Back to top
chimeric.de = chi`s home Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0