/* TV Rimote BY M.Kikuchi Tiny13a 9.6MHz 2013/12/20 ROM 368 Bytes conf=1F 7A */ sbit Inf_LED at PORTB4_bit; char SW_data[]={ 0x02,0xfd,0x48,0xb7 // Power }; void Inf_PS(char Pcunt){ char l; // 1=26uSec (25.83) for(l=0;l< Pcunt;l++){ Inf_LED=1; Delay_us(12); Inf_LED=0; Delay_us(12); asm { nop ; nop ; nop ; nop ; nop ; } } } void IFR_9000(){ Inf_PS(174); Inf_PS(174); } void Inf_zero(){ //650+450=1100 Inf_PS(25); Delay_us(450); //try } void Inf_one(){ //650+1550=2200 Inf_PS(25); Delay_us(1550); } void Send_Command(){ char l1,l2,Tmp; IFR_9000(); Delay_us(4400); // 32bit for (l1=0;l1<4;l1++){ Tmp=SW_data[l1]; for (l2=0;l2<8;l2++){ if ((Tmp & 0x80)==0x80) Inf_one(); else Inf_zero(); Tmp <<=1; } } Inf_zero(); // 33bit stop Delay_ms(39); } void Repeet_M(){ IFR_9000(); Delay_us(2200); Inf_zero(); //stop bit } void main() { DDRB =0b00010000; // 4bit=IFR LED PORTB=0; while(1){ Send_Command(); Repeet_M(); // Delay_ms(100); // // Repeet_M(); // while(1); //LOOP } }