IR Phototransistor and IR Led Emitter Scematic Setup and Code To Read

Use your favorite search engine and the phrase "arduino phototransistor schematic" to open up an entire world of intriguing ideas.

Use a 220 Ohm resistor in series with your IR LED, between the port pin and GND.