Cara, muito bom o site. Consegui criar um código:
sbit LCD_RS at RB0_bit; sbit LCD_EN at RB1_bit; sbit LCD_D4 at RB2_bit; sbit LCD_D5 at RB3_bit; sbit LCD_D6 at RB4_bit; sbit LCD_D7 at RB5_bit; sbit LCD_RS_Direction at TRISB0_bit; sbit LCD_EN_Direction at TRISB1_bit; sbit LCD_D4_Direction at TRISB2_bit; sbit LCD_D5_Direction at TRISB3_bit; sbit LCD_D6_Direction at TRISB4_bit; sbit LCD_D7_Direction at TRISB5_bit; //----------------------------------------------------------------------------// sbit IR_Bit at RA3_bit; sbit IR_Bit_Dir at TRISA3_bit; //----------------------------------------------------------------------------// void IR_Init(){ IR_Bit_Dir=1; IR_Bit=0; } //----------------------------------------------------------------------------// unsigned short IR_Receber(){ unsigned short BRI[8]={0,0,0,0,0,0,0,0}, BRIT=0; if (!IR_Bit){ Delay_us(13500); for (BRIT=0;BRIT<8;BRIT++){ Delay_us(1125); if (IR_Bit)BRI[BRIT]=0; else { Delay_us(1125); BRI[BRIT]=1; } } BRIT=0; if (BRI[0]==1) BRIT = BRIT + 1; if (BRI[1]==1) BRIT = BRIT + 2; if (BRI[2]==1) BRIT = BRIT + 4; if (BRI[3]==1) BRIT = BRIT + 8; if (BRI[4]==1) BRIT = BRIT + 16; if (BRI[5]==1) BRIT = BRIT + 32; if (BRI[6]==1) BRIT = BRIT + 64; if (BRI[7]==1) BRIT = BRIT + 128; } return BRIT; } //----------------------------------------------------------------------------// void main(){ char TXT[3]; unsigned short Receber=0, Cont=0; CMCON=0x07; IR_Init(); Lcd_Init(); Lcd_Cmd(_LCD_CLEAR); Lcd_Cmd(_LCD_CURSOR_OFF); Lcd_Out(1,1,"Teste com IR"); Lcd_Out(2,1,"Byte:"); //6 while(1){ Receber=IR_Receber(); if (Receber != 0){ ShortToHex(Receber,TXT); Lcd_Out(2,6,TXT); Delay_ms(200); } } } //----------------------------------------------------------------------------//
Porém os botões variam entre três valores. O botão ON/OFF varia entre:
0001 1000 0000 1111 0000 1100
O que acha que pode ser?