partime
- 24th May 2009, 07:28
I want to use infrared communication to increase/decrease the score on a scoreboard. So, if I press one button on a remote, then the score will increase by one. And, if another button is pressed, then the score gets decreased by one. The score is output to a dual 7-segment LED display. This is what I have done so far.
First, I setup a PIC627 to increase the count by one everytime I pressed a button which was hardwired to the PIC. Next, I removed the button and added a PIC628a to act as the button. I bought the Infrared Communications kit from Rentron.com (http://www.rentron.com/remote_control/infrared-serial.htm) and used the PNA4602M detector to be the input to the PIC628a. I programmed it so the output would go high when an infrared signal was detected. This worked. I could use any remote I had and the count would increase everytime I pressed any button. Lastly, I assembled the transmitting part of the kit I got from Rentron. I used a simple SEROUT command to be transmitted. And again, the count would increase when the signal was detected. So, I think I sort of have the up count figured out. I am new to most of this and I took small steps to get where I am now. I started with the simple counter and just added to it.
Here is some of the programming I have used:
PIC627 - gets input from portb.7 and increase cnt by 1 when button is pressed
BUTTON Pbutton, 1, 255,0, i, 0, LOOP 'pbutton = portb.7
pause 100
Cnt = Cnt + 1
GOTO LOOP
The count would increase very rapidly when the remote button was press just montentarly, so I added the pause. This helped slow things down. I'm not sure if this best command to use to increase the count or not. It was okay when I just used this chip hardwired to a button. But, now since I want the increase to be triggered by an IR signal, I'm not sure it is the best choice to use.
PIC628a - gets input from the PNA4602M detector and outputs to the 627 as a button
loop:
IF PORTB.0 = 0 Then
high PORTB.1
else
low PORTB.1
endif
goto loop
So, if an infrared signal is detected, then a high signal is output to portb.7 on the PIC627.
PIC84 - used to produce the data to be transmitted
TRISB = 0
ADDRESS VAR BYTE
DAT VAR BYTE
ID VAR BYTE
ADDRESS = 10
ID = 25
BEGIN:
FOR DAT = 0 TO 255
SEROUT PORTB.0,4,[ID,ADDRESS,DAT]
PAUSE 100
NEXT
GOTO BEGIN
This is just the code I got off the Rentron website, just to test that things were working. The output is NANDed with 38 kHz carrier frequency. Having this setup, the diplay will count up very fast because of the constant signal that is being generated.
My next task is to add a way to decrease the count. This is were I think I am going to need some guidance. Ideally, I would like to be able use an old TV remote and just use one button on the remote to increase the count and another to decrease it. Otherwise, I believe that I will need to add pushbuttons which produce different SEROUT data. Or something like that.
I can probably reduce the number of PICs that I am using. I just used each PIC to accomplish a given task and simplify things.
Hopefully this isn't too much information, but I wanted to give a good idea of what I have setup. Do I look like I am going in the right direction with things? Any input would be appreciated. Thanks.
First, I setup a PIC627 to increase the count by one everytime I pressed a button which was hardwired to the PIC. Next, I removed the button and added a PIC628a to act as the button. I bought the Infrared Communications kit from Rentron.com (http://www.rentron.com/remote_control/infrared-serial.htm) and used the PNA4602M detector to be the input to the PIC628a. I programmed it so the output would go high when an infrared signal was detected. This worked. I could use any remote I had and the count would increase everytime I pressed any button. Lastly, I assembled the transmitting part of the kit I got from Rentron. I used a simple SEROUT command to be transmitted. And again, the count would increase when the signal was detected. So, I think I sort of have the up count figured out. I am new to most of this and I took small steps to get where I am now. I started with the simple counter and just added to it.
Here is some of the programming I have used:
PIC627 - gets input from portb.7 and increase cnt by 1 when button is pressed
BUTTON Pbutton, 1, 255,0, i, 0, LOOP 'pbutton = portb.7
pause 100
Cnt = Cnt + 1
GOTO LOOP
The count would increase very rapidly when the remote button was press just montentarly, so I added the pause. This helped slow things down. I'm not sure if this best command to use to increase the count or not. It was okay when I just used this chip hardwired to a button. But, now since I want the increase to be triggered by an IR signal, I'm not sure it is the best choice to use.
PIC628a - gets input from the PNA4602M detector and outputs to the 627 as a button
loop:
IF PORTB.0 = 0 Then
high PORTB.1
else
low PORTB.1
endif
goto loop
So, if an infrared signal is detected, then a high signal is output to portb.7 on the PIC627.
PIC84 - used to produce the data to be transmitted
TRISB = 0
ADDRESS VAR BYTE
DAT VAR BYTE
ID VAR BYTE
ADDRESS = 10
ID = 25
BEGIN:
FOR DAT = 0 TO 255
SEROUT PORTB.0,4,[ID,ADDRESS,DAT]
PAUSE 100
NEXT
GOTO BEGIN
This is just the code I got off the Rentron website, just to test that things were working. The output is NANDed with 38 kHz carrier frequency. Having this setup, the diplay will count up very fast because of the constant signal that is being generated.
My next task is to add a way to decrease the count. This is were I think I am going to need some guidance. Ideally, I would like to be able use an old TV remote and just use one button on the remote to increase the count and another to decrease it. Otherwise, I believe that I will need to add pushbuttons which produce different SEROUT data. Or something like that.
I can probably reduce the number of PICs that I am using. I just used each PIC to accomplish a given task and simplify things.
Hopefully this isn't too much information, but I wanted to give a good idea of what I have setup. Do I look like I am going in the right direction with things? Any input would be appreciated. Thanks.