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
| IP | Address | What it is |
|---|
chaser | 0x7000 | the chaser, driving all six LEDs while it runs |
leds | 0x1000 | the six LEDs while the chaser is stopped |
buttons | 0x2000 | buttons S1 and S2 |
sys | 0x0 | design information |
The registers of chaser (byte offsets):
| Offset | Name | Access | Meaning |
|---|
0x0 | ctrl | rw | bit 0: run; bit 1: reverse. Writing 0 to bit 0 stops the chase and returns the LEDs to leds |
0x4 | pattern | rw | LEDs to light (bit 0 = LED 0). Writing it restarts the chase from this pattern |
0x8 | rate | rw | steps per second (0 to 65535); 0 holds the pattern still |
0xc | current | ro | current chaser pattern (shown on the LEDs while running) |
0x10 | steps | ro | steps 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.