Juin 072014

Still on my journey to a wordclock…

In the previous article, we have seen how to use a shift register to control up to 8 digital outputs (or more if you cascade IC’s).

One drawback in the previous setup is that we had to use one transistor per digital output (to control a device powered by another source).
That is 8 extra transistors, 8*3 extra wires, etc : not very practical and especially if we intend to control several shift registers IC’s. (i plan on using 3 in my wordclock project)

So this is where the ULN2803 comes in : 8 NPN transistors and one common ground in one integrated circuit.


See below a refreshed schema (compared to the previous article). Note that I have decided to power my IC’s with my (regulated) Arduino 5v but I could as well have used my battery pack power.
Our 74HC595 will control our ULN2803 (by sending HIGH or LOW on the input) which in turn will drive the current thru each output/led.


the Arduino sketch :

//the pins we are using
int latchPin = 2;
int clockPin = 3;
int dataPin = 4;
void setup() {
  //set all the pins used to talk to the chip
  //as output pins so we can write to them
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
void loop() {
  for (int i = 0; i < 8; i++) {
    //take the latchPin low so the LEDs don't change while we are writing data
    digitalWrite(latchPin, LOW);
    //shift out the bits
    shiftOut(dataPin, clockPin, MSBFIRST, i);  
    //take the latch pin high so the pins reflect
    //the data we have sent
    digitalWrite(latchPin, HIGH);

    // pause before next value:

  5 Responses to “Arduino : use a shift register (74HC595) and a transistor array (ULN2803)”

  1. I was planning on doing exactly what you are describing in this post, but I was just reading about an alternate high-powered shift register (TPIC6A595) that outputs up to 100mA on each pin, as opposed to the 6mA or so that the 74HC595 outputs.

    I’m curious if you know anything about the TPIC6A595?


    • I dont know about the TPIC6A595 but I believe the arduino is there to deliver logic not power.
      Hence the 74HC595 is ok for me since I deliver power from a dedicated power source.


  2. Thanks to share the detailed schematics. I will use it to control 2x 4-phase stepper motor.


  3. […] : play with a potentiometer Arduino : use a transistor Arduino : use a shift register (74HC595) Arduino : use a shift register (74HC595) and a transistor array (ULN2803) Arduino : shift out leds Arduino : Cascade two 74HC595 Arduino : Cascade two 74HC595 (video) […]

  4. Hello, I’m looking for a pic target board from a pickit3 that can output 24v. I need to write a code for the outputs in assembly and c language on mplabx.

    Any advice or guidance you can give me – is this possible?

    kind regards,

    Llion Stephen – I have this board from digikey and thinking of buying ULN2803A



 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>



Ce site utilise Akismet pour réduire les indésirables. En savoir plus sur comment les données de vos commentaires sont utilisées.