7.5 Shift Register Binary Counter

The goal of this project is to demonstrate how to expand digital outputs using a 74HC595 shift register.
With just three pins from the NULA MINI, we can control multiple LEDs — an essential concept when working with limited I/O pins.
This example creates a 4-bit binary counter, displaying values from 0 to 15 across four LEDs connected to the shift register.
It teaches how to send serial data to the register, latch it, and visualize binary counting in real time.
In this documentation you will learn:
- How a 74HC595 shift register works and connects to the NULA MINI
- How to use the
shiftOut()function to send serial data - How to control multiple LEDs using only three output pins
- How to visualize binary numbers using LEDs
Hardware required
- 1× Soldered NULA MINI board
- 1× 74HC595 shift register
- 4× LEDs
- 4× 330 ohm resistors
- Breadboard
- Jumper wires
- USB-C cable

How it works
The 74HC595 is an 8-bit serial-in, parallel-out shift register.
It allows you to send 8 bits of data one at a time through a single data pin.
When all bits are loaded, you latch the output — updating all LEDs at once.
In this project, the NULA MINI sends 4-bit values (0–15) representing a binary counter.
Each LED corresponds to one bit of that number:
| Decimal | Binary | LED pattern (Q3 Q2 Q1 Q0) |
|---|---|---|
| 0 | 0000 | All OFF |
| 1 | 0001 | Rightmost LED ON |
| 7 | 0111 | Three right LEDs ON |
| 15 | 1111 | All ON |

Wiring and connections
| 74HC595 Pin | Function | NULA MINI Pin | Description |
|---|---|---|---|
| DS (Pin 14) | Serial Data Input | IO2 | Data sent from NULA MINI |
| SH_CP (Pin 11) | Clock | IO4 | Shifts each bit into the register |
| ST_CP (Pin 12) | Latch | IO3 | Updates LED outputs |
| Q0–Q3 (Pins 15,1,2,3) | Outputs | 4 LEDs (via 220 Ω resistors) | Display binary value |
| MR (Pin 10) | Master Reset | 5V | Keeps register active |
| OE (Pin 13) | Output Enable | GND | Enables outputs |
| VCC (Pin 16) | Power | 5V | Power supply |
| GND (Pin 8) | Ground | GND | Common ground |


Full code
Below is the full example code for this project:
int latchPin = 3; // ST_CP pin (Latch)
int clockPin = 4; // SH_CP pin (Clock)
int dataPin = 2; // DS pin (Data)
int counter = 0; // 4-bit counter (0–15)
void setup() {
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
void loop() {
// Limit counter to 4 bits (0–15)
byte value = counter & 0x0F;
digitalWrite(latchPin, LOW); // Prepare shift register for data
shiftOut(dataPin, clockPin, MSBFIRST, value); // Send data bits
digitalWrite(latchPin, HIGH); // Latch outputs to LEDs
counter++; // Increment counter
if (counter > 15){
counter = 0; // Wrap around to 0 after 15
}
delay(500); // Wait half a second
}
Full example

Check out the full example code on the link below:
7.5_Shift_Register_Binary_Counter.ino
Project demonstrating how to use a 74HC595 shift register to control four LEDs as a 4-bit binary counter using only three NULA MINI pins.