how to move using 12V fan using Arduino and transistor

I would like to move using 12V fan using Arduino and transistor only when I push the tactile switch. So, the electricity schematic I am currently thinking is attached. the specifications and the code are as follows. Is it correct? if not, please let me know where my error is and how I should modify.

-the specification of 12V fan I use-
URL:https://www.amazon.co.jp/gp/product/B00YH7A7LY/ref=ppx_yo_dt_b_asin_title_o03_s00?ie=UTF8&psc=1
model number:CFZ-4010LA
size:40✖️40✖️10mm
rated voltage:DC12V 1.20W

-the specification of transistor I use-
URL:http://www.grandpas-shack.com/parts/datasheets/2SD2012.pdf
model number:2SD2012
rated voltage:Vce=60V , Vcb=60V , Veb=7V, Ic=3A, hFE=100

-code-
int buttonstate ;
void setup() {
pinMode(13, OUTPUT);
pinMode(8, INPUT_PULLUP);
}

void loop() {
buttonstate = digitalRead(8);
if (buttonstate == 0) {
digitalWrite(13, HIGH);
}
else {
digitalWrite(13, LOW);
}

}

Looks OK to me. What happens when you try it?

Hint: to test the program logic, you don't need to connect a motor or the transistor. Just use a current limiting resistor and an LED to indicate "motor on/off".

It should work however there is a LED connected to pin 13, try another pin to be sure it is not giving you a false reading.

There is NO LED connected to D13 on an Uno - D13 drives the input of a comparator (1uA load) the comparator drives the LED.

jremington:
Looks OK to me. What happens when you try it?

Hint: to test the program logic, you don't need to connect a motor or the transistor. Just use a current limiting resistor and an LED to indicate "motor on/off".

I tried to build the electricity schematic but unfortunately it doesn't work. Perhaps, there might be some problems in the electricity schematic. please let me know where my error are and how I should modify. By the way, I used just a rectifier diode not LED to protect transistor from counter electromotive force DC fan motor generates. In addition, I decided to use 8 dry cell battery to supply 12V.

Diode looks backward to me, cathode (end with black band) should be connected to +12V, not transistor collector, that's a short circuit.

Thank you for your response. it works well after I modify as you said.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.