motor circuit issue

I was following something online about motors with the arduino uno. Breadboard Layout | Arduino Lesson 13. DC Motors | Adafruit Learning System.
I tried to recreate the circuit in the image and i wrote my own very simple code and uploaded to my board but nothing happened. Can someone please point out my mistake or error.

My sketch:

int motorPin = 3;
void setup() 
{ 
  pinMode(motorPin, OUTPUT);
} 
 
void loop() 
{ 
analogWrite(motorPin, 150);
}

My circuit

Im using a
bs548 transistor
410 ohm resistor
Arduino uno smd
standard dc motor

The circuit from the website.

Your picture is a little dim around the transistor, but it looks like the base resistor might be going to the wrong pin.
Also if you're only setting the analog pin once, you should move the analogWrite to setup(). If it's in loop() it's getting set over and over at high speed, which can ruin the PWM timing.

Standard caveats:

  • How much current do you expect the motor to draw?
  • Have you measured it? (Quite likely more than the Arduino can supply, or the transistor.)
  • To see if the motor turns at all, use analogWrite(motorPin, 255);
  • Wrong transistor - should be BD135-BD139 and 220 ohm resistor.

Test with this:

int motorPin = 3;
void setup() 
{ 
  pinMode(motorPin, OUTPUT);
  analogWrite(motorPin, 255);
} 
 
void loop() 
{ 
}

Hi.
Quote from adafruit site with this fritzy drawing.

The motor that comes with Adafruit Arduino kits does not draw more than 250mA but if you have a different motor, it could easily draw 1000mA, more than a USB port can handle! If you aren't sure of a motor's current draw, power the Arduino from a wall adapter, not just USB

I'd be very worried about drawing even 100mA from 5V, the tracks on the circuit board are not able to handle 250mA let alone 1Amp.
Oh well they just sell you another UNO.
Tom.... :slight_smile:

TomGeorge:
I'd be very worried about drawing even 100mA from 5V, the tracks on the circuit board are not able to handle 250mA let alone 1Amp.

Recently I designed a small circuit board with high currents and dense tracks.
So I had to calculate track width carefully.
I was amazed by what tracks can handle.
In this case, 250mA, with 25 degrees temp rise, only needs 0.025mm. 1/4 of a human hair.
Not wise to design it that small, but still...
Leo..