Average of reading on IR sensor

Here is the code for the IR that could help you.
http://www.ladyada.net/learn/sensors/ir.html