Skip to main content

fabricgate / chaserVerified

Autonomous 6-LED chaser with configurable pattern, rate, and direction for nanopynq

License: MITAuthor: FabricGate Project
fabricgate pull fabricgate/chaser:1.0.0 --platform tangnano20k/nanopynq

Versions

Platforms (v1.0.0)

tangnano20k/nanopynqtangnano9k/nanopynq

LED chaser

A light that runs along the six on-board LEDs. You write the pattern and the speed once; after that the circuit moves the LEDs by itself. Your code can finish, or even stop, and the LEDs keep running because the FPGA does the work, not the notebook.

Built with nanopynq. Nothing to install: in Chrome or Edge, on this version's page, select your board, press Open the panel, then Write to the board, Connect, and Open the notebook.

What is on the board

IPAddressWhat it is
chaser0x7000the chaser, driving all six LEDs while it runs
leds0x1000the six LEDs while the chaser is stopped
buttons0x2000buttons S1 and S2
sys0x0design information

The registers of chaser (byte offsets):

OffsetNameAccessMeaning
0x0ctrlrwbit 0: run; bit 1: reverse. Writing 0 to bit 0 stops the chase and returns the LEDs to leds
0x4patternrwLEDs to light (bit 0 = LED 0). Writing it restarts the chase from this pattern
0x8raterwsteps per second (0 to 65535); 0 holds the pattern still
0xccurrentrocurrent chaser pattern (shown on the LEDs while running)
0x10stepsrosteps completed since bit 0 of ctrl was set

Each step moves every lit LED one place (wrapping from LED 5 back to LED 0).

Try it

The first cell of the notebook writes ctrl=1, pattern=2, rate=3: one LED runs along at three steps a second. Run ol.chaser.register_map a few times: current and steps change between runs, with no code running in between.

Two lights, three LEDs apart, faster, in the other direction:

ol.chaser.write(0x4, 0b001001)   # pattern: LEDs 0 and 3
ol.chaser.write(0x8, 10)         # 10 steps a second
ol.chaser.write(0x0, 0b11)       # run in reverse

Check the speed: the circuit counts its own steps.

import time
s = ol.chaser.read(0x10)
time.sleep(2)
(ol.chaser.read(0x10) - s) / 2   # about 10 steps a second

Speed it up and slow it down. Press Stop to end the loop; the LEDs keep running at the last speed:

import time
while True:
    for r in list(range(1, 40)) + list(range(40, 1, -1)):
        ol.chaser.write(0x8, r)
        time.sleep(0.1)

Stop the chase with ol.chaser.write(0x0, 0). The LEDs then follow leds, for example ol.leds[0].on().

From local Python with pip install "nanopynq[fabricgate]":

from nanopynq import Overlay

ol = Overlay("fabricgate://fabricgate/chaser:1.0.0", board="tangnano9k")  # or board="tangnano20k"

License

MIT License. Copyright (c) 2026 FabricGate Contributors.