Seven Segments 2 digits with 2 digital pins + 595, etc..., how to wire-control??

Hi!, :slight_smile: I need some help to wire and control a Seven Segments 2 digits with 2 digital pins :cold_sweat: :~


1 C segment cathode
2 DP segment cathode
3 E segment cathode
4 D segment cathode
5 G segment cathode
6 F segment cathode
7 Digital 1 common anode
8 Digital 2 common anode
9 B segment cathode
10 A segment cathode

connected through 74HC595 :

From Q0 to Q7 → from A to DP (punto)


DS to 8
SH_CP to 7 (Clock)
ST_CP to 9 (Latch)

Sample code: Counter 0 a 99


//Pin connected to ST_CP of 74HC595
int latchPin = 9;
//Pin connected to SH_CP of 74HC595
int clockPin = 7;
////Pin connected to DS of 74HC595
int dataPin = 8;

int LED_SEG_TAB[]={0x01,0x60,0xda,0xf2,0x66,0xb6,0xbe,0xe0,0xfe,0xf6};
//                   0    1    2    3    4    5    6    7    8    9

int counts;
byte ten_e1, ten_e0;

void setup() 
  //set pins to output so you can control the shift register
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);

void loop() 
  for (int counts = 0; counts < 100; counts++)
    ten_e1 = counts / 10;     //SACA LA DECENA
    ten_e0 = counts % 10;     //SACA LA UNIDAD
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, LSBFIRST, LED_SEG_TAB[ten_e0]);   // LSD
    shiftOut(dataPin, clockPin, LSBFIRST, LED_SEG_TAB[ten_e1]);  
    digitalWrite(latchPin, HIGH);

Finally wiring Display: “7 Digital 1 common anode” through 220 Ohm to GND and show numbers ok.
How I can control two digits with the same 795?
If I connect Display: “7 Digital 2 common anode” to the same GND or to 595 pin 9 named Q7´ show the same digit in each display :cold_sweat: :drooling_face: :roll_eyes:

Ty so much :slight_smile: Sorry, my english it’s so bad… xD Say ty to Spanish’s education system… xD :stuck_out_tongue: Pls,correct-me if you like :slight_smile:

Add a Serial.print after these 2 lines, confirm you are getting 2 different #s: ten_e1 = counts / 10; //SACA LA DECENA ten_e0 = counts % 10; //SACA LA UNIDAD

Do you have Q7' from one chip going to SerDataIn on the next chip?

Ok, show’s number.

I dont understand well the wiring scheme to control the second digital pin from Display(see Pinout)
I need 2 795 to control 1 display?? I mean, if the leds of display are controled by 795 and the data “in” to Display through:

-Digital 1 common anode
-Digital 2 common anode

Its posible control with one? I found an example, it does using digital pins in arduino, but that’s for 4 common anode pins, I’ve “2bit Common cathode Digital Tube 0.56in. red LED”

#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 2

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress insideThermometer;

const int ledPin =  13;// LED connected to digital pin 13
const int latchPin = 8;//Pin connected to ST_CP of 74HC595
const int clockPin = 9;//Pin connected to SH_CP of 74HC595
const int dataPin = 10;//Pin connected to DS of 74HC595

const int digitPins[4] = {
  3,4,5,6}; //pins to control the 4 common anode pins of the display

const byte digit[10] = //seven segment digit bits
  B00111111, //0
  B00000110, //1
  B01011011, //2
  B01001111, //3
  B01100110, //4
  B01101101, //5  B01101101B01001111
  B01111101, //6
  B00000111, //7
  B01111111, //8
  B01101111  //9

int digitBuffer[4] = {
int digitScan = 0;
int soft_scaler = 0;
float tempC, tempF;
int tmp;

void setup()   {                
  TCCR2A = 0;
  TCCR2B = (1<<CS21);
  TIMSK2 = (1<<TOIE2);
  TCNT2 = 0;

  pinMode(ledPin, OUTPUT); 
  for(int i=0;i<4;i++)
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);  

  sensors.getAddress(insideThermometer, 0);

ISR(TIMER2_OVF_vect) {
    soft_scaler = 0;

void refreshDisplay()
  for(byte k=0;k<4;k++)
    digitalWrite(digitPins[k], LOW);
  digitalWrite(latchPin, LOW);  
  shiftOut(dataPin, clockPin, MSBFIRST, B11111111);
  digitalWrite(latchPin, HIGH);
  digitalWrite(digitPins[digitScan], HIGH); 

  digitalWrite(latchPin, LOW);  
    shiftOut(dataPin, clockPin, MSBFIRST, ~(digit[digitBuffer[digitScan]] | B10000000)); //inserting the dot
    shiftOut(dataPin, clockPin, MSBFIRST, ~digit[digitBuffer[digitScan]]);
  digitalWrite(latchPin, HIGH);
  if(digitScan>3) digitScan=0;

void loop()                     
  digitalWrite(ledPin, HIGH);
  tempC = sensors.getTempC(insideThermometer);
  tempF = DallasTemperature::toFahrenheit(tempC);
  tmp = int(tempF*100);
  digitBuffer[3] = tmp/1000;
  digitBuffer[2] = (tmp%1000)/100;
  digitBuffer[1] = (tmp%100)/10;
  digitBuffer[0] = (tmp%100)%10;

  digitalWrite(ledPin, LOW);

Hope this helps with the hardware connections and a description of what the software needs to do.

Thank you so much!

Tomorrow I will try to wire and complile some simple sketch and will be back with bad or good news :)

I've some 2N4401 Transistor NPN, and will try with 220ohm resistors, right?

Ty again :)

Current limit resistor to the LEDs: (5V-(Vf of LED)/.008 = resistor 8mA because the 74HC595 has a 70mA total limit.

juanpintom: I need 2 795 to control 1 display??

There are 8 outputs per per 74HC595. A 2x (7 segments + DP) display requires 16 inputs, thus you either need 2x 74HC595 chips (see Nick's example) or you need to switch repeatedly between the digits as shown in reply #3 by CrossRoads.

Ty Crossroads 8) That work’s!!

I’m working on it!