Noob transistor circuit problem

Hello everyone, I have just started learning arduino through a well known book and I'm trying to control a 5v dc motor with a npn transistor as described in the examlple.

Problem is when I upload the sketch (copied and pasted from the book, so I know it's correct) the motor runs constantly and not per the sketch which is on for a second - delay- off for a second.

I have triple checked breadboard connections and the data sheet for the transistor to make sure base, collector, emitter pins are correct. Anyone know why the motor runs constantly?

Hey man,

As I posted a noob question myself the other day and got some help I thought I would return the favour.

I guess the best advice would be to take it apart, delete the sketch and start again fresh.

You also may want to double check you have the transistor in the correct way round and that you are using the correct transistor (look closely at it, take a note of the letters/numbers on it and google it with the word “datasheet” after it), anything other than npn transistor and you have used the wrong component component(mentioned due to the temp sensor looking very similar).

To double check the code part you could take the motor/resistor stuff out and put in an led and resisor circuit into the pin output to see if it blinks as expected.

Cheers

That's NOT the correct way. The diodes should be over the motor (aka between transistor collector and the 9V). Not to the 5V line, now they are useless.

Worse than useless, they are routing 9V direct into 5V through the motor winding and frying the Arduino.

Diodes go across the inductive load. They provide a safe route for current to flow from the inductor.

Hi Guys, thank you for your replies and suggestions. I will take the circuit apart for the 4th time and give it another go.

I will double check the pins against the data sheet tonight but I'm sure they are correct and will also test the circuit with an led. I had a diode across the motor as described in the example. I will post back with any updates.

Cheers

While you are at it, swap the transistor as well. You might have damaged it in an earlier attempt.