Need help with opto fork

I am new to Arduino coding so I don't quite understand how it works just yet and could use some help.

If I've got a wire running from the 5V pin to D8 through an opto fork how can I code it to light up the orange LED in the middle of the board only when something is interrupting the signal?

Thanks in advance.

WTF is an opto fork? Do you mean a slotted optical interrupter? A tutorial. What board?

Sorry, yeah. An opto fork is just what my teacher called it. The board is an UNO

Without more details (such as what exact device you use - post link to datasheet, that failing at least the part number) there's not much to say about it.

The orange led in the middle of which board? The Uno I guess because students with only a basic knowledge of electronics would not be trusted to calculate and use the correct values of current limiting resistors for the “opto fork” etc.
Probably you want to use the following statements in the loop()
digitalRead( )
digitalWrite( ) Hint: the Uno led is on pin 13
And in setup() you’ll need pinMode().