analogWrite(pin, 0) ouputs 0.104V?

Hi,
I am trying to drive a motor via PWM, but when I want to turn it off using analogWrite(pin, 0), I can stil hear hum from the motor. If I measure voltage on the PWM pin (nothing attached on it i.e. only uC pin) it reads 0.104V. It makes no change if I set the pin as output or not. How to solve it?

If this problem cannot be overcome, how to exchange analogWrite and digitalWrite? The following does not work:
pinMode(pin, OUTPUT); //=in Setup. Not needed for analogWrite
if (Speed == 0) {
analogWrite(pin, 0);
digitalWrite(pin, 0);
} else {
//digitalWrite(pin, 1); ?!?!?!? what to do here?
analogWrite(pin, Speed);
}

Probably the voltage is coming from your motor driver. Have you checked without any shield or the like connected?

Pure pin, only arduino/uC, hanging in the air.

What is the value of "pin"?

Have you read this?

BTW, how are you measuring the voltage?

The pin is PCI28/OC1B/(Digital 12)/PD4/pin18 on ATMEL ATMEGA644P/SANGUINO.
So: pin=12.

I checked wiring.h and wiring_analog.c for sanguino and everything is OK. Translates to:
sbi(TCCR1A, COM1B1); // connect pwm to pin on timer 1, channel B
OCR1B = val; // set pwm duty

PWM works great at >0.

hacker007:
If this problem cannot be overcome, how to exchange analogWrite and digitalWrite? The following does not work:

analogWrite does that anyway:

void analogWrite(uint8_t pin, int val)
{
	pinMode(pin, OUTPUT);
	if (val == 0)
	{
		digitalWrite(pin, LOW);
	}
...

I would like to see all your code, and your wiring.

I use the connection in attachment but without variac.
Other thing I noticed is if I use analogWrite(pin, 255) the motor is not fully ON (compared to speed achieved by linking gate of IRFZ via resistor in picture directly to +5V)?!
I call MowerSpeed(255); or with 0.

const int Mower = 12;

void MowerSpeed (unsigned char MowerSpeed) {
//0-255 0=off 255=full on
if ((SoftStart == (SoftBOTH - 1)) || (MowerSpeed > 127)) {
for (unsigned char a = 0; a < MowerSpeed; a++) {
analogWrite(Mower, a);
delay(10);
}
SoftStart = 0;
}
analogWrite(Mower, MowerSpeed);
}

Tnx in advance.

PWM IRFZ44n.jpg

  for (unsigned char a = 0; a < MowerSpeed; a++) {
      analogWrite(Mower, a);

Where did you get the idea that analogWrite() takes an unsigned char as the second argument? It takes an int. Yes, I know that is not reasonable, given the valid range of values that it accepts, but, it is what it is. At least, use byte for the loop index, not unsigned char.

By the way, pin 12 is not a PWM pin.

PaulS:
By the way, pin 12 is not a PWM pin.

It is on a Sanguino, which the OP said they are using.