I used this code in arduino to read the receiver
#include <avr/interrupt.h>
#include <avr/io.h>
#define TIMER_RESET TCNT1 = 0
#define SAMPLE_SIZE 64
int IRpin = 2;
unsigned int TimerValue[SAMPLE_SIZE];
char direction[SAMPLE_SIZE];
byte change_count;
long time;
void setup() {
Serial.begin(115200);
Serial.println("Analyze IR Remote");
TCCR1A = 0x00; // COM1A1=0, COM1A0=0 => Disconnect Pin OC1 from Timer/Counter 1 -- PWM11=0,PWM10=0 => PWM Operation disabled
// ICNC1=0 => Capture Noise Canceler disabled -- ICES1=0 => Input Capture Edge Select (not used) -- CTC1=0 => Clear Timer/Counter 1 on Compare/Match
// CS12=0 CS11=1 CS10=1 => Set prescaler to clock/64
TCCR1B = 0x03; // 16MHz clock with prescaler means TCNT1 increments every 4uS
// ICIE1=0 => Timer/Counter 1, Input Capture Interrupt Enable -- OCIE1A=0 => Output Compare A Match Interrupt Enable -- OCIE1B=0 => Output Compare B Match Interrupt Enable
// TOIE1=0 => Timer 1 Overflow Interrupt Enable
TIMSK1 = 0x00;
pinMode(IRpin, INPUT);
}
void loop()
{
Serial.println("Waiting...");
change_count = 0;
while(digitalRead(IRpin) == HIGH) {}
TIMER_RESET;
TimerValue[change_count] = TCNT1;
direction[change_count++] = '0';
while (change_count < SAMPLE_SIZE) {
if (direction[change_count-1] == '0') {
while(digitalRead(IRpin) == LOW) {}
TimerValue[change_count] = TCNT1;
direction[change_count++] = '1';
} else {
while(digitalRead(IRpin) == HIGH) {}
TimerValue[change_count] = TCNT1;
direction[change_count++] = '0';
}
}
Serial.println("Bit stream detected!");
change_count = 0;
time = (long) TimerValue[change_count] * 4;
Serial.print(time);
Serial.print("\t");
Serial.println(direction[change_count++]);
while (change_count < SAMPLE_SIZE) {
time = (long) TimerValue[change_count] * 4;
Serial.print(time);
Serial.print("\t");
Serial.println(direction[change_count-1]);
Serial.print(time);
Serial.print("\t");
Serial.println(direction[change_count++]);
}
Serial.println("Bit stream end!");
delay(2000);
}
then i get these results
when i send command from transmitter
Waiting...
Bit stream detected!
0 0
8892 0
8892 1
13436 1
13436 0
13940 0
13940 1
14560 1
14560 0
15092 0
15092 1
15668 1
15668 0
16200 0
16200 1
16820 1
16820 0
17324 0
17324 1
17924 1
17924 0
18428 0
18428 1
19056 1
19056 0
19536 0
19536 1
20184 1
20184 0
20664 0
20664 1
21284 1
21284 0
21816 0
21816 1
22392 1
22392 0
22924 0
22924 1
24676 1
24676 0
25156 0
25156 1
26884 1
26884 0
27392 0
27392 1
29144 1
29144 0
29648 0
29648 1
31380 1
31380 0
31888 0
31888 1
33640 1
33640 0
34144 0
34144 1
35876 1
35876 0
36400 0
36400 1
38084 1
38084 0
38616 0
38616 1
40344 1
40344 0
40848 0
40848 1
42604 1
42604 0
43108 0
43108 1
44836 1
44836 0
45344 0
45344 1
47096 1
47096 0
47580 0
47580 1
48204 1
48204 0
48708 0
48708 1
49328 1
49328 0
49836 0
49836 1
50436 1
50436 0
50940 0
50940 1
52668 1
52668 0
53176 0
53176 1
53800 1
53800 0
54304 0
54304 1
54904 1
54904 0
55456 0
55456 1
56056 1
56056 0
56564 0
56564 1
57160 1
57160 0
57664 0
57664 1
59420 1
59420 0
59928 0
59928 1
61656 1
61656 0
62160 0
62160 1
63912 1
63912 0
64420 0
64420 1
Bit stream end!
I want when i pressed the on/off button led switch on and switch off
and my IR version is YK-001
please help