Search

Arduino and ULN2003APG

Please let us in the comment zone any suggestions that you think will improve the article!

If you like the article click the follow button  to stay in touch with us!

 

First of all  what is ULN2003PG?

ULN2003PG is an seven npn Darlington transistors array driver  , which works at maximum 50V and 500mA per output. This device is ideal in application where you need amplification including powering of induction loads because it has flyback diodes, which protect the driver.

To understand better let’s see the images below:

ULN2003APG

This is the entire structure of the driver.As you can see it has 7  inputs, 7 outputs, 1 gnd and 1 common pin.

Now each input-output pair it has a structure like the one below:

ULN2003APG

On the input you can apply a digital signal , for example from an arduino and the transistors structure work as a switch.

So, when you have a HIGH state on the input (5V), the transistors are polarized and the output pin is connected to the ground. If you have a load between common and output it will be powered on.

Now you can understand why in the first picture appear some inversor symbols, becase when you have a high input(logical “1”) your output will be connected to the ground(“0”) and the load would be powered on.

If we simplify the image above we have the basic switch connection with an npn transistor for induction loads:

npn as a switch

Now for the first example we have powered on a dc motor which start every time when pin 13 is in HIGH state like in the image(i used the blink program with an 3 seconds off time):

ULN2003 and a dc motor

 



 

And a small video:

Now the main purpose of this driver is to power step by step motors. Before to explain how it is working i must say something about the motor i used.

Is an unipolar motor because it has 5 wires- red,yellow,brown,orange and black.

The red wire is the common wire for the coils and the others the coil ends like in the image below:

step by step motor

So, we will connect the red wire to VCC and the others at the ULN driver like:

yellow-pin 1

brown-pin 2

orange-pin 3

black – pin 4

As i mentioned above the outputs of the ULN driver connect the load to the gnd. So, if you connect the red wire to vcc or common and all the other wires to the outputs of the driver, when you enable an input, the corresponding output will connect the wire to the ground and so the coil will be powered on.

If we enable the inputs at a succsessive rate the motor will be powered on.

A test program  for a step by step motor with an ULN 2003APG and arduino is:

int motorpin1 = 3;
int motorpin2 = 4;
int motorpin3 = 5;
int motorpin4 = 6;
int t =20;

void setup() {
pinMode(motorpin1, OUTPUT);
pinMode(motorpin2, OUTPUT);
pinMode(motorpin3, OUTPUT);
pinMode(motorpin4, OUTPUT);
}

void loop() {
digitalWrite(motorpin1, HIGH);
digitalWrite(motorpin2, LOW);
digitalWrite(motorpin3, LOW);
digitalWrite(motorpin4, LOW);
delay(t);
digitalWrite(motorpin1, LOW);
digitalWrite(motorpin2, HIGH);
digitalWrite(motorpin3, LOW);
digitalWrite(motorpin4, LOW);
delay(t);
digitalWrite(motorpin1, LOW);
digitalWrite(motorpin2, LOW);
digitalWrite(motorpin3, HIGH);
digitalWrite(motorpin4, LOW);
delay(t);
digitalWrite(motorpin1, LOW);
digitalWrite(motorpin2, LOW);
digitalWrite(motorpin3, LOW);
digitalWrite(motorpin4, HIGH);
delay(t);
}

A short video about that is:

 

Facebooktwitterpinterest

Related posts

One thought on “Arduino and ULN2003APG

  1. bahha

    Thank you, I controlled a DC motor with your method, I came across some threads where responses were saying it was impossible and suggested other ways.
    cheers !

Leave a Comment

Show Buttons
Hide Buttons