Simplified IR sensor code