I am assuming the infrared sensor you are referring to is the IR seeker sensor. If you download Xander's driver suite (
http://botbench.com/blog/robotc-driver-suite/), it contains many sample programs. One of which is the IR seeker sample (hitechnic-irseeker-v2-enhanced-test1.c). That will give you an idea on how to program this sensor.