optocoupler software issue need help

so I am trying to get the arduino to read a 12-13.8v signal through an optocoupler, I know the optocoupler works as i can get it to turn on/off an LED withouth the arduino. however When I try to get the arduino to read a high/low from the optocoupler output cuircut and power pin 4 when high and not when low, the led just remains iluminated. here is my code and following that is how i have wired the optocoupler;

int optoInput = 7;
int grnLed = 4;

void setup()
{
pinMode(optoInput, INPUT);
pinMode(grnLed, OUTPUT);
}
void loop()
{
if (digitalRead(optoInput) == HIGH)
{
digitalWrite(grnLed, HIGH);
}
else
{
digitalWrite(grnLed, LOW);
}
}

What am I doing wrong?

Connect the other output lead of the opto to pin 7, the lead that was on pin 7 to ground, lose the
resistor and do

  pinMode (7, INPUT_PULLUP) ;

Then the opto is acting just like a push-button switch.

Your current configuration is always pulling pin 7 HIGH through the leakage current of the opto's outputs.

added pic

optoexample.bmp (174 KB)

Thanks pancake works fine now.