Fan control speed code /RPM working

Hello Folks,

I am trying to control my 12V fan , I have followed this topic :

Everything work i can see the RPM with the monitor then i would like to manage my fan to turn on or off

So i tried this :

int TIP120pin = 11; //for this project, I pick Arduino's PMW pin 11
void setup()
{
pinMode(TIP120pin, OUTPUT); // Set pin for output to control TIP120 Base pin
analogWrite(TIP120pin, 0); // By changing values from 0 to 255 you can control motor speed
}

void loop()
{
}

I have respected the pin;(the variable name does not matter i believe) .

Anyone could help me to know why the fan does not turn off?

Please change the code to use code tags

Second, the variable name suggests a transistor. So what I miss is a schematic.

Sorry i am new to the forum .

Well i use the same schema as the link

But the code could be

int fan = 11; //for this project, I pick Arduino's PMW pin 11
void setup()
{
pinMode(fan, OUTPUT); // Set pin for output to control TIP120 Base pin
analogWrite(fan, 0); // By changing values from 0 to 255 you can control motor speed
}

If i use "tip 120" or "fan" it's just the variable so won't change anything ?

I just would like to get a code/schema to manage ON/OFF with the arduino

EDIT : i have 3 wire fan and i also try this tuto http://www.instructables.com/id/Use-Arduino-with-TIP120-transistor-to-control-moto/

The schematic for reading the RPM will not help you to drive it... (And can even damage things)

You indeed need to use a transistor. A TIP120 or a random logic level MOSFET will do. The last link tells you all about it. So does Googling for "Arduino motor"

Flammeur:
If i use "tip 120" or "fan" it's just the variable so won't change anything ?

You can't use the first one. Variables can't contain space characters.

Thanks for the answer but this tuto didn't work for me http://www.instructables.com/id/Use-Arduino-with-TIP120-transistor-to-control-moto/

Do you have any topic to advice?

Edit : I checked with Dc mortor but they have only 2wire and i have 3 on the fan (the yellow one) does it means i don't need to use it?
And i use external battery as it's 12v FAN

Flammeur:
Edit : I checked with Dc mortor ...

What was the result?

I use the tuto from the starter kit book for DC motor and it worked ! Thanks for all the quick answer.

Last questions to power the arduino i use the vin pin does the arduino support 12V battery? if not how could i do?