digitalRead wont respond when PIN is high

G'Day All,

I can't get my head around why this code will not acknowledge the PIN value when it's high.
I'm just practicing to learn.
The code works when the PIN is low but not when high, ie there is no serial print ( +++ etc) when the pin is high.
The routine controls the fan as coded except for the serial print when the PIN is high.

/*
Sketch to run 12v fan.
Fan + to 12v, fan - to BC547 Collector.
BC547 Emitter to ground and Base to pin #8.

MB 17/03/12
*/

int switchPIN = 8;

void setup()

{
Serial.begin(9600);
pinMode(switchPIN,OUTPUT);
Serial.println(" CONTROLLING A FAN ");
}

void loop()
{

digitalWrite(switchPIN, HIGH);
Serial.println(" FAN ON");
int pinval = digitalRead(switchPIN);
if (pinval == HIGH) {
Serial.println("+++");
}
delay(3000);
digitalWrite(switchPIN, LOW);
Serial.println(" FAN OFF");
pinval = digitalRead(switchPIN);
if (pinval == LOW) {
Serial.println("---");
}
delay(3000);
digitalWrite(switchPIN, HIGH);
Serial.println(" FAN ON LONG");
pinval = digitalRead(switchPIN);
if (pinval == HIGH) {
Serial.println("L+++");
}
delay(9000);
digitalWrite(switchPIN, LOW);
Serial.println(" FAN OFF LONG");
pinval = digitalRead(switchPIN);
if (pinval == LOW) {
Serial.println("L---");
}
delay(9000);

}

Duhh !!

Problem solvered, I had omitted the base resistor so I guess the transistor was suffering and pulled the pin down.

You are calling digitalWrite on a pin configured for OUTPUT. This turns the internal pull-up resistor on and off.

Edit: Senior moment...

You are calling digitalWrite on a pin configured for OUTPUT. This turns the internal pull-up resistor on and off.

Senior moment?