Go Down

Topic: RE: USD INPUT CAPTURE TO MAKE A INFARED DECODER (Read 725 times) previous topic - next topic

pxii007

AS THE TOPIC SHOW,

WHAT I DO FIRST IS TO CAPTURE THE TIME BETWEEN EACH SIGNAL FROM IR SENSOR AND NEXT IS TO DECODE THE MEANING OF THE TIME.

1.I CONNECT THE IR SENSOR TO THE PIN8 (BECAUSE ITS SECONDE FUNCTION IS ICP1)
2.MAKE THE CODE BELOW

PROBLEM:A LOT OF DATA FROM SERIAL MONITOR EVEN THOUGH THERE IS NO IR SIGNAL... :-[

I PUSH THE BUTTON ON TV CONTROL N FIND OUT THE SHOW OF THE SERIAL MONITOR SPEED UP. I GUESS THE IR SENSOR HV SOME REFLECITON WITH THE TV CONTROL.



PLS CHK THE CODE BELOW

#include <avr/interrupt.h>
#include <avr/io.h>
#include "WProgram.h"
//#include <avr/signal.h>

#define TIFR1_SET  TIFR1|=_BV(ICF1)
#define TCNT1_CLR TCNT1=0
#define TCCR1B_UPINVOKE TCCR1B|=_BV(ICES1)
#define TCCR1B_DOWNINVOKE TCCR1B&=~_BV(ICES1)
#define TCCR1B_16_DIV TCCR1B|=_BV(CS11)//16M 8 DIV 0.5US
#define TTCR1B_ICNC1  TCCR1B|=_BV(ICNC1)
#define TCCR1A_SET TCCR1A=0
#define TIMSK1_INPUT_INTERRUPT_ENABLE TIMSK1|=_BV(ICIE1)
#define GET_INPUT(x) x=ICR1
#define IS_UPINVOKE TCCR1B&_BV(ICES1)
#define SEI sei()

int data0,data1;
char bitcnt=0;
int icr=-1;
ISR(TIMER1_CAPT_vect)
{
 static int old;
 int temp;
 TCNT1_CLR;
 GET_INPUT(icr);
 temp = icr-old;
 old=icr;
Serial.println(icr);
}
void interruptInit()
{
 TCNT1_CLR;
 TCCR1A_SET;
 TCCR1B_UPINVOKE;
 TTCR1B_ICNC1;
 TCCR1B_16_DIV;
 TIFR1_SET;
 TIMSK1_INPUT_INTERRUPT_ENABLE ;
}
void setup()
{
  interruptInit();
   Serial.begin(9600);
   SEI;
}
void loop()
{
}

pxii007

THE HARDWARE CONNECTION

P33 IS NO CONNECTION.

Go Up