ir remote control code help
I have a awesome bot that uses a h-bridge that I made myself that consits or relays and a couple of transistors. Everything is perfect except for two things. I am using a ir remote control from a sony tv, so it has a quite limited range. When the bot gets out of range then ir does not receive the brake signal from the remote. Also when it loses the signal then it just keeps going eventually hitting a wall. I would use a contact sensor of some sort but it goes way to fast and is too heavy to stop from top speed to zero in under the distance of a foot. I also would use a ping sensor, but I am really tight on money, due to me spending it all on an 8800gt and q6600. I have no idea how to make the bs2 sense, that there was no signal for 100 ms, and therefor stop. I have the code here to make your lives esiaer. 
The gosub makelow is the braking techique I use.

' {$STAMP BS2}
' {$PBASIC 2.5}
time VAR Word
irPulse VAR Word
remoteCode VAR Byte
t VAR Word
b VAR Word
LOW 12
LOW 13
LOW 14
LOW 15
PAUSE 100
start:
DO
GOSUB remote
GOSUB move
remoteCode = 15
LOOP
remote: ' Main DO...LOOP
Get_Pulses: ' Label to restart message check
remoteCode = 0 ' Clear previous remoteCode
' Wait for resting state between messages to end.
DO
RCTIME 9, 1, irPulse
LOOP UNTIL irPulse > 1000
' Measure start pulse. If out of range, then retry at Get_Pulses label.
RCTIME 9, 0, irPulse
IF irPulse > 1125 OR irPulse < 675 THEN GOTO Get_Pulses
' Get Data bit pulses.
RCTIME 9, 0, irPulse
IF irPulse > 300 THEN remoteCode.BIT0 = 1
RCTIME 9, 0, irPulse
IF irPulse > 300 THEN remoteCode.BIT1 = 1
RCTIME 9, 0, irPulse
IF irPulse > 300 THEN remoteCode.BIT2 = 1
RCTIME 9, 0, irPulse
IF irPulse > 300 THEN remoteCode.BIT3 = 1
RCTIME 9, 0, irPulse
IF irPulse > 300 THEN remoteCode.BIT4 = 1
RCTIME 9, 0, irPulse
IF irPulse > 300 THEN remoteCode.BIT5 = 1
RCTIME 9, 0, irPulse
IF irPulse > 300 THEN remoteCode.BIT6 = 1
' Map digit keys to actual values.
IF (remoteCode < 10) THEN remoteCode = remoteCode + 1
IF (remoteCode = 10) THEN remoteCode = 0
DEBUG CLS, ? remoteCode
RETURN
backwardall:
HIGH 12
HIGH 13
HIGH 14
LOW 15
RETURN
forwardall:
HIGH 12
LOW 13
HIGH 15
HIGH 14
RETURN
goright:
HIGH 12
HIGH 13
LOW 15
LOW 14
PAUSE 100
RETURN
goleft:
HIGH 12
LOW 13
HIGH 15
LOW 14
PAUSE 100
RETURN
makelow: ' brake
LOW 12
LOW 13
LOW 14
LOW 15
RETURN
light:
HIGH 0
PAUSE 100
RCTIME 0, 1, time
DEBUG HOME, " time = " ,DEC5 time
RETURN
move:
GOSUB makelow
IF remoteCode = 117 THEN
GOSUB backwardall
ENDIF
IF remoteCode = 116 THEN
GOSUB forwardall
ENDIF
IF remoteCode = 52 THEN
GOSUB goleft
ENDIF
IF remoteCode = 51 THEN
GOSUB goright
ENDIF
IF remoteCode = 101 THEN
GOSUB makelow
ENDIF
PAUSE 100
RETURN
The gosub makelow is the braking techique I use.

Comments
Post Edit -- sp.
This is a written medium and sometimes things don't come across as well as they might verbally or in person. Some people sound a bit acerbic or sometimes "half assed" in this medium. Sometimes it's their sense of humor and sometimes it's because English is not their native language. You won't get much help if you call people names, particularly if you want something from them.
Post Edited (Mike Green) : 3/23/2008 10:16:47 PM GMT
This means you have to press the keys, or hold them down, to keep the robot in motion. This then becomes a problem if you have more than one robot, because two remotes will jam each other, if you hold a key down.
But that's the classic solution.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
rebroadcast whatever IR signal it detects. This is useful if you want to steer or get a signal to/from your robot around the corner, down the hallway, anywhere out of the·line of sight. A 38 kHz IR detector needs to be positioned towards the source (your handheld remote), then that triggers an LM555 circuit oscillating at 38 kHz to send the same received code to one or more IR LEDs aimed in a new direction (around·a corner or doorway). Obviously you don't want a feedback problem where the detector sees the same LEDs it's controlling, so you'll have to be careful about that. Minimally invasive wiring between detector & LEDs could be run on the wall around a corner, or around a doorjam. Alternatively, you could drill a small hole through a wall or ceilings·to route·the two or 3 small wires required. Clearly, you'd want to power this with an AC adapter, not batteries, so access to an outlet will figure in as well. Seems like you could daisy chain these together so A triggers B, B triggers C, etc. if the output signal is clean enough.
Lots of·info on the web, but I'm going to start with http://www.cedarnet.org/smartware/Hardware/IR_Repeater/
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
Radio Shack used to sell a pair of small pyramids -- a reciever that would take the IR-Remote signal, send it via RF to a second pyramid, which would then output a copy of the original IR-Signal. For about $25 for the pair. You can't really build anything that cheaply, that effectively.
At the very least, buy a pair and use them as a prototype to check out the concept.