Built-in project · Arduino Uno R3

Hex digits through a 74HC595 (pins 11, 8 and 12), on an Arduino Uno

A 74HC595 with DS on pin 11, SH_CP on 8 and ST_CP on 12 drives a one-digit display through all sixteen hexadecimal digits, 0 to F. The whole build, an Arduino Uno and 3 more parts, runs here in your browser on the firmware below; open it in the editor to change the wiring or the code and run it again.

Teaching? Assign it to your class in one click.

Intermediate Runs in your browser. Free, and no account needed.

Hex digits through a 74HC595 (pins 11, 8 and 12) · Arduino Uno R3live0.000 s 0.00x
Click to open it in the editor
The circuit itself, running here on the simulator. Press what can be pressed; click anything else to open it in the editor.

The code

The firmware exactly as the editor opens it. Change a line there and press Run: it compiles in the browser.

sketch.ino · Arduino Uno R3
// A 74HC595 drives one seven-segment digit: 0 to 9, then A to F.
//
//   74HC595 DS -> pin 11    SH_CP -> pin 8    ST_CP -> pin 12
//   74HC595 VCC and MR -> 5V      GND and OE -> GND
//   Q0 to Q6 -> segments a to g, Q7 -> the dot
//   the display's common cathode -> 220 ohm -> GND
//
// shiftOut() sends a byte one bit at a time on DS, with a pulse on SH_CP for
// each bit; a pulse on ST_CP then copies all eight to the outputs at once.
// With MSBFIRST and segment a in the lowest bit, bit 0 ends up on Q0.

const int DS = 11;
const int SHCP = 8;
const int STCP = 12;

//                      gfedcba
const byte HEX_DIGITS[16] = {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07,
                             0x7F, 0x6F, 0x77, 0x7C, 0x39, 0x5E, 0x79, 0x71};
const char SYMBOLS[] = "0123456789ABCDEF";

void setup() {
  pinMode(DS, OUTPUT);
  pinMode(SHCP, OUTPUT);
  pinMode(STCP, OUTPUT);
  Serial.begin(9600);
  Serial.println("Mokxi Uno: 74HC595 on pins 11, 8 and 12");
}

void loop() {
  for (int i = 0; i < 16; i++) {
    digitalWrite(STCP, LOW);
    shiftOut(DS, SHCP, MSBFIRST, HEX_DIGITS[i]);
    digitalWrite(STCP, HIGH);
    Serial.println(SYMBOLS[i]);
    delay(1000);
  }
}

Parts list

5 parts, plus the jumper wires. Every one is in the editor's parts bin.

How it is wired

13 connections, pin by pin, read from the circuit itself. Each line is one set of pins joined together, by a jumper wire or a breadboard strip.

  • Ground: Arduino Uno R3 pin GND; 74HC595 shift register pin GND; 74HC595 shift register pin OE; Resistor, 220 Ω pin 2
  • Arduino Uno R3 pin 12; 74HC595 shift register pin STCP
  • Arduino Uno R3 pin 11; 74HC595 shift register pin DS
  • Arduino Uno R3 pin 8; 74HC595 shift register pin SHCP
  • Arduino Uno R3 pin 5V; 74HC595 shift register pin MR; 74HC595 shift register pin VCC
  • 74HC595 shift register pin Q1; Seven segment display pin B
  • 74HC595 shift register pin Q2; Seven segment display pin C
  • 74HC595 shift register pin Q3; Seven segment display pin D
  • 74HC595 shift register pin Q4; Seven segment display pin E
  • 74HC595 shift register pin Q5; Seven segment display pin F
  • 74HC595 shift register pin Q6; Seven segment display pin G
  • 74HC595 shift register pin Q0; Seven segment display pin A
  • Seven segment display pin COM1; Resistor, 220 Ω pin 1

Change it and keep it

Open it in the editor, change the circuit or the code, and keep your version in a free account.