Thanks again for your help Dave. I pretty much used your RF receiver code and modified it for use with the IR signal. Here is the code I used on an 16F84A with a 4 MHz crystal. I used it to test if the channel up button was pressed on the remote.
I get LED to go high when I press the channel up button.Code:define PULSIN_MAX 968 IRPIN var PORTB.0 LED var PORTB.1 LED2 var PORTB.2 RF var byte[4] Header var word PULSE_LENGTH var byte i var byte INIT: RF[0]=0 RF[1]=0 RF[2]=0 RF[3]=0 i=0 Pulsin IRPIN, 0, Header if (Header < 792) then INIT while irpin = 0:wend repeat pulsin IRPIN, 1, PULSE_LENGTH if (PULSE_LENGTH < 40) or (PULSE_LENGTH > 175) then INIT if (PULSE_LENGTH > 90) then RF.0(i) = 1 else rf.0(i) = 0 endif i=i+1 until (i>31) if (RF[3]=230) then high LED pause 500 low LED else high LED2 pause 500 low LED2 endif goto INIT end
It took me awhile to figure out how the data was arranged in the array. I started out using RF[0]=10 to light LED, but kept getting LED2 to light up. So, I thought there was something screwed up with the values pulsin was generating. Finally, I read through the FAQ on arrays and figured out my problem. I used RF[0]=80 and got LED to light up. However, LED would light up with any button I pushed since all the buttons used the same starting code. So, I ended up using RF[3] to test if channel up was pressed.
Is testing RF[3] going to be the best way to determine which button is pushed? I plan to use channel up/channel down for one team and volume up/volume down for the other team.





Bookmarks