So I've been working on this project for some time now and I've hit a wall since I'm new to using pickit3 and using C language is not my strong. Basically what I'm trying to do is use two micro-controllers to communicate to each other using an infrared I've manage to program the first PIC which creates different pulses using various input combination using 4 switches. For example (0000 = 200 us pulse,0001 =250 us pulse). now for the receiver i need to capture the pulses and display them using 4 LED's (200us = 0000, 250us = 0001). the code below is the code i did for the First micro-controller. MY question is how would I do the receiver part of the code. i know i should use Timer1 or Timer0 from reading the data sheets. but i havent been able to work something out even from using other examples where people make use of these timers/counters.
main(){
ANSEL =0b000000;
TRISC=0b110111;
PORTC=0b000000;
OSCCAL=0b11111;
while(1){
if (RC0==0 && RC1==0 && RC2==0 && RC4==0){
RC3=1;
__delay_us(183);
RC3=0;
__delay_us(166);}
else if (RC0==0 && RC1==0 && RC2==0 && RC4==1){
RC3=1;
__delay_us(229);
RC3=0;
__delay_us(196);}
else if (RC0==0 && RC1==0 && RC2==1 && RC4==0){
RC3=1;
__delay_us(276);
RC3=0;
__delay_us(234);}
else if (RC0==0 && RC1==0 && RC2==1 && RC4==1){
RC3=1;
__delay_us(322);
RC3=0;
__delay_us(264);}
else if (RC0==0 && RC1==1 && RC2==0 && RC4==0){
RC3=1;
__delay_us(368);
RC3=0;
__delay_us(318);}
else if (RC0==0 && RC1==1 && RC2==0 && RC4==1){
RC3=1;
__delay_us(415);
RC3=0;
__delay_us(348);}
else if (RC0==0 && RC1==1 && RC2==1 && RC4==0){
//500us
RC3=1;
__delay_us(460);
RC3=0;
__delay_us(385);}
else if (RC0==0 && RC1==1 && RC2==1 && RC4==1){
//550us
RC3=1;
__delay_us(508);
RC3=0;
__delay_us(415);}
else if (RC0==1 && RC1==0 && RC2==0 && RC4==0){
//600us
RC3=1;
__delay_us(555);
RC3=0;
__delay_us(500);}
else if (RC0==1 && RC1==0 && RC2==0 && RC4==1){
//650us
RC3=1;
__delay_us(600);
RC3=0;
__delay_us(530);}
else if (RC0==1 && RC1==0 && RC2==1 && RC4==0){
//700us
RC3=1;
__delay_us(646);
RC3=0;
__delay_us(568);}
else if (RC0==1 && RC1==0 && RC2==1 && RC4==1){
//750us
RC3=1;
__delay_us(694);
RC3=0;
__delay_us(600);}
else if (RC0==1 && RC1==1 && RC2==0 && RC4==0){
//800us
RC3=1;
__delay_us(738);
RC3=0;
__delay_us(650);}
else if (RC0==1 && RC1==1 && RC2==0 && RC4==1){
//850us
RC3=1;
__delay_us(785);
RC3=0;
__delay_us(680);}
else if (RC0==1 && RC1==1 && RC2==1 && RC4==0){
//900us
RC3=1;
__delay_us(828);
RC3=0;
__delay_us(718);}
else if (RC0==1 && RC1==1 && RC2==1 && RC4==1){
//950us
RC3=1;
__delay_us(880);
RC3=0;
__delay_us(750);}
}}