Built-in project · Arduino Uno R3

Sink chaser on an Arduino Uno

An NLSF595, the 595 with open-drain outputs, runs a dot along seven LEDs that hang from 5 V: a 0 bit pulls an output low and lights its LED. The whole build, an Arduino Uno and 15 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.

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

Sink chaser · 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
// Sink chaser: seven LEDs on an NLSF595, the 595 whose outputs sink current.
//
// Wiring, driver to board:
//   SI   (pin 14, serial data)    -> pin 4
//   SCK  (pin 11, shift clock)    -> pin 5
//   RCK  (pin 12, register clock) -> pin 6
//   SCLR (pin 10) to 5 V, OE (pin 13) to GND
//   each LED from 5 V through 220 ohm, its cathode to QB..QH (QA is free)
//
// The NLSF595's datasheet calls it functionally similar to a 74VHC595, and
// shiftOut() and a latch pulse drive it the same way. The difference is the
// outputs: they are open drain. A stored 0 pulls the output to ground and
// lights the LED wired to it; a stored 1 lets go and the LED goes dark. So
// the sketch sends the inverse of the pattern it wants to see.
//
// This is how the chip drives common-anode RGB LEDs: the anode to 5 V and
// each color's cathode to an output.

const int DATA_PIN = 4;   // SI
const int SHIFT_PIN = 5;  // SCK
const int LATCH_PIN = 6;  // RCK

static void show(uint8_t lit) {
  // Invert: a 0 bit is a lit LED on an open-drain output.
  shiftOut(DATA_PIN, SHIFT_PIN, MSBFIRST, (uint8_t)~lit);
  digitalWrite(LATCH_PIN, HIGH);
  digitalWrite(LATCH_PIN, LOW);
}

void setup() {
  Serial.begin(9600);
  pinMode(DATA_PIN, OUTPUT);
  pinMode(SHIFT_PIN, OUTPUT);
  pinMode(LATCH_PIN, OUTPUT);
  show(0);
  Serial.println("NLSF595 ready");
}

void loop() {
  // Bit n is output Qn: bit 1 is QB, bit 7 is QH.
  for (int i = 1; i < 8; i++) {
    show((uint8_t)(1 << i));
    delay(90);
  }
  for (int i = 6; i > 1; i--) {
    show((uint8_t)(1 << i));
    delay(90);
  }
}

Parts list

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

How it is wired

19 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; NLSF595 tri-color LED driver pin GND; NLSF595 tri-color LED driver pin OE
  • Arduino Uno R3 pin 6; NLSF595 tri-color LED driver pin RCK
  • Arduino Uno R3 pin 5; NLSF595 tri-color LED driver pin SCK
  • Arduino Uno R3 pin 4; NLSF595 tri-color LED driver pin SI
  • Arduino Uno R3 pin 5V; NLSF595 tri-color LED driver pin SCLR; NLSF595 tri-color LED driver pin VCC; Resistor, 220 Ω (1) pin 1; Resistor, 220 Ω (2) pin 1; Resistor, 220 Ω (3) pin 1; Resistor, 220 Ω (4) pin 1; Resistor, 220 Ω (5) pin 1; Resistor, 220 Ω (6) pin 1; Resistor, 220 Ω (7) pin 1
  • NLSF595 tri-color LED driver pin QB; LED, red (1) pin C
  • NLSF595 tri-color LED driver pin QC; LED, red (2) pin C
  • NLSF595 tri-color LED driver pin QD; LED, red (3) pin C
  • NLSF595 tri-color LED driver pin QE; LED, red (4) pin C
  • NLSF595 tri-color LED driver pin QF; LED, red (5) pin C
  • NLSF595 tri-color LED driver pin QG; LED, red (6) pin C
  • NLSF595 tri-color LED driver pin QH; LED, red (7) pin C
  • Resistor, 220 Ω (1) pin 2; LED, red (1) pin A
  • Resistor, 220 Ω (2) pin 2; LED, red (2) pin A
  • Resistor, 220 Ω (3) pin 2; LED, red (3) pin A
  • Resistor, 220 Ω (4) pin 2; LED, red (4) pin A
  • Resistor, 220 Ω (5) pin 2; LED, red (5) pin A
  • Resistor, 220 Ω (6) pin 2; LED, red (6) pin A
  • Resistor, 220 Ω (7) pin 2; LED, red (7) pin A

Change it and keep it

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

Free forever. Every board and part. Saves your projects. Works on Chromebooks.