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.

uln2803

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.

uln2803a_bb

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:
    delay(1000);
  }
}

4
Poster un Commentaire

avatar
3 Fils de commentaires
1 Réponses de fil
0 Abonnés
 
Commentaire avec le plus de réactions
Le plus populaire des commentaires
3 Auteurs du commentaire
ArssantadminBen Vigil Auteurs de commentaires récents

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

  S’abonner  
plus récent plus ancien
Notifier de
Ben Vigil
Invité
Ben Vigil

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?

Ben

Arssant
Invité

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

Arssant

trackback

[…] : 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) […]