Hi, I am trying to build a program for my 16F676 which can help it learn at least 1 code from any IR transmitter. Two LEDs (red and green) to be connected to my PIC, one button & one IR receiver. When button is pressed PIC should go to the learning mode.
Then while in learning mode someone to press a button on ANY ir remote and PIC will learn that button code. Every time that particular button is pressed, green LED to glow for 1 sec else RED will stay ON.
I have a code I use currently, but it involves me making my own transmitter as well, since I can control pulses coming out from my own transmitter, it is easy to program the receiver to catch those pulses (Thanks to Bruce for his codes on his website).
Code:
PULSIN PORTA.3,0,PULSE_IN '// Read-in start pulse
IF (PULSE_IN < 200) OR (PULSE_IN = 0) OR (PULSE_IN > 270) THEN Decode2 '// Less than Start pulse, then keep looking
Verify:
FOR Index = 0 TO 15 '// Setup to read-in 16 pulses
PULSIN PORTA.3,0,IR_PULSE[Index] '// Read 13 low-going pulses on RA.7
NEXT Index '// Loop x times
DBYTE = $FF '// Start with all 1's and find each 0
ABYTE = $FF '// Start with all 1's and find each 0 in pattern
FOR Index = 0 TO 7 '// Get 8 "data" bits
IF IR_PULSE[Index] < 85 THEN DBYTE.0[Index]=0
IF IR_PULSE[Index+8] < 85 THEN ABYTE.0[Index]=0
NEXT Index
-------------------------------------------------------------------------------------------------------
Since now I want to train my PIC to learn any sort of pulse from any sort of transmitter, I am totally confused as to how my PIC will learn that. I have to sync with some start bit to make this happen. But there are so many protocols, that I need a little help to achieve this.
Bookmarks