Electronics, music instruments
| Home |
|---|
| One-shot |
| Microled |
| Moduled Nano |
| Moduled Rack |
| Lunt |
| Lunt Preview |
| Resources |
| PO-24 Cheat Sheet |
MIDI-enabled controller for dimmable AC light bulbs, with on-device manual control.
Lunt drives up to four 110/220 V dimmable bulbs through an AC dimmer module. A toggle switch selects between MANUAL (set each bulbβs brightness by hand, or over MIDI) and ANIMATION (pick from self-running light shows). An 8-LED NeoPixel strip is the on-device display β warm yellow in MANUAL, red in ANIMATION.
βΆ Live animation preview β an interactive simulation of all 8 light shows on four Edison-style bulbs, no hardware needed.
π₯ Lunt CV β an alternate firmware that swaps ANIMATION for a CV input, so the bulbs flash with drum hits (e.g. via a ZOIA envelope follower).
An Arduino Nano controls the four channels of an AC Light Dimmer Module via phase-cut dimming (the Dimmable Light library, synced to the AC zero-cross on D2), and reads MIDI on its hardware serial port.
The toggle switch picks the mode:
| Control | Action | | β | β | | Turn encoder right / left | Brighter / dimmer (the selected target) | | Press encoder | Cycle the target: ALL β 1 β 2 β 3 β 4 β STRIP β TEMPO β SUBDIV (defaults to ALL) |
After the four bulbs there are three setting targets (turn the encoder to adjust each):
STRIP_BRIGHTNESS_MIN.No MIDI/clock info is shown on the strip in MANUAL mode itself β only these toggles.
MIDI also drives brightness here (channel 15 by default, MIDI_CHANNEL in the sketch):
| Message | Mapping |
|---|---|
Note On / Off C4βD#4 (60β63) |
Turn bulbs 1β4 on/off (Note On velocity sets the on-brightness, Note Off turns it fully off) |
| CC 22 / 23 / 24 / 25 | Brightness of bulb 1 / 2 / 3 / 4 |
| CC 27 | Brightness of all bulbs at once |
The strip is warm yellow: ALL lights every pixel, Light N lights the Nth pixel (counted from the left). While you turn the encoder it shows a brightness bar, then reverts to the pixel number.
Entering MANUAL mode resets all bulbs to mid brightness (MANUAL_RESET_BRIGHTNESS),
so nothing stays stuck at whatever level an animation left it.
The strip is red. Each of the 8 animations sits on one of the 8 pixels. See them all in the live animation preview.
| Control | Action |
|---|---|
| Turn encoder (in menu) | Move the cursor over the 8 animations (the lit pixel = selection) |
| Press encoder (in menu) | Enter the highlighted animation |
| Turn encoder (running) | Adjust the animation (speed, or β with a MIDI clock β the beat subdivision) |
| Short press (running) | Re-sync: restart the animation at that instant β tap on the beat to line it up with the music |
| Long hold (running) | Exit back to the selection menu (LONG_PRESS_MS) |
| # | Animation | What it does |
|---|---|---|
| 1 | Comet | A bright spot sweeps 1β2β3β4 with a fading tail |
| 2 | Larson | A single bright bulb bounces 1β4β1 (Knight Rider) |
| 3 | Sine | A simple sine LFO β all four bulbs fade up and down together; rate follows the BPM, divided by a subdivision |
| 4 | Drift | Each bulb is its own slow oscillator, wandering in and out of phase independently (0 spread = all breathe together) |
| 5 | Twinkle | Random bulbs sparkle bright then fade |
| 6 | Build & drop | Fills 1β12β123β1234, blackout, repeat |
| 7 | Waves | A slow, smooth sine swell rolling in and out across the bulbs; never goes fully dark |
| 8 | 6/8 Pulse | For a 6/8 feel: bulbs 1 & 2 flash-and-fade on beats 1β3 (strongβmediumβweak), then 3 & 4 on beats 4β6, repeating |
Sine is a plain LFO β all four bulbs together. Its SINE_SUBDIV parameter sets how
many beats one cycle takes: 1, 1/2, 1/3, 1/4, 1/5, 1/6, 1/7, 1/9 (i.e. one cycle every
1, 2, 3 β¦ 9 beats), defaulting to 1/4. SINE_MIN_PCT / SINE_MAX_PCT set the trough
and peak brightness as a percent of full β default 2%β66%, so it never goes fully dark
or fully bright.
Drift gives each bulb its own oscillation rate, so they wander in and out of phase
independently β calming, organic, never a marching wave. Its one parameter (DRIFT_SPREAD)
sets how far the rates spread: 0 = all in sync (a plain breathe), higher = more
independent. It defaults to a slow ~30 BPM.
Waves is a calming, continuous sine. Its phase spread (the offset between adjacent bulbs) sets the feel β 0Β° is all bulbs in phase, ~90Β° is a wave rolling across the row β and a brightness floor keeps a minimum glow. It defaults to a slow ~40 BPM.
Here each of the six beats is one count of the 6/8 measure, so one free-run beat = one flash; 6/8 Pulse defaults to 120 BPM (the other animations default to ~135).
MIDI clock: when a clock is running, the animation beat-locks and the encoder selects the subdivision β 1 bar Β· 1/2 Β· 1/4 Β· 1/8 Β· 1/16 (shown as 1β5 red pixels). With no clock, the encoder sets a free speed of 20β250 BPM (shown as a red bar). MIDI notes/CC are ignored in ANIMATION mode.
Clock indicators (right two pixels, while an animation is running):
Each can be turned off via the MANUAL TEMPO / SUBDIV targets. If the tempo pixel never turns purple while you send clock, the Arduino isnβt receiving it (see Troubleshooting).
β οΈ The dimmer module switches mains AC. Wire and enclose the AC side carefully.
All control pins are on the Arduino Nano:
| Arduino pin | Connected to | Notes |
|---|---|---|
| D0 (RX) | MIDI input circuit output | Hardware serial; disconnect while uploading (see below) |
| D2 | Dimmer SYNC (zero-cross) | Must be an interrupt pin; required by the dimmer library |
| D9 | Dimmer CH1 | Bulb 1 gate |
| D7 | Dimmer CH2 | Bulb 2 gate |
| D5 | Dimmer CH3 | Bulb 3 gate |
| D6 | Dimmer CH4 | Bulb 4 gate |
| D3 | Encoder CLK (A) | Β |
| D8 | Encoder DT (B) | Β |
| D12 | Encoder button | INPUT_PULLUP |
| A1 (D15) | NeoPixel DIN | 8 pixels |
| A0 (D14) | Mode switch | INPUT_PULLUP; other switch terminal to GND |
Power: dimmer module and NeoPixel VCC/GND to the Nanoβs 5V/GND; encoder and
switch grounds to GND.
MIDI input is an opto-isolated circuit (6N138 + 1N914 + 4.7k + 220 ohm) feeding the Nanoβs RX (D0). See the SparkFun MIDI tutorial for the standard input schematic.
Mode switch logic: with the internal pull-up, the switch idles HIGH (= MANUAL) and
reads LOW when closed to GND (= ANIMATION). Flip ANIM_MODE_LEVEL in the sketch if your
two modes come out reversed.
Adjustable knobs are grouped in the CONFIG / KNOBS section at the top of the sketch.
See Tunable parameters for the full list with values and ranges.
Install via the Arduino Library Manager:
Build with the Arduino AVR Boards core 1.8.3 β see Troubleshooting for why.
All are const (or #define) in the CONFIG / KNOBS block at the top of lunt.ino,
except where noted. Pins are in the Wiring table. βRangeβ is the sensible
working range, not the data-type limit.
| Variable | Value | Range | Description |
| β | β | β | β |
| ANIM_MODE_LEVEL | LOW | LOW / HIGH | Switch level that selects ANIMATION (the other position is MANUAL). |
| ENCODER_STEP | 8 | 1β32 | Brightness / free-speed change per encoder detent. |
| BUTTON_DEBOUNCE_MS | 200 | 50β500 | Minimum ms between accepted encoder-button presses. |
| SWITCH_DEBOUNCE_MS | 50 | 20β200 | The mode switch must hold a level this long before the mode changes (rejects noise from the dimmer). |
| LONG_PRESS_MS | 600 | 300β1500 | Hold time to exit an animation (shorter = a re-sync). |
| MANUAL_RESET_BRIGHTNESS | 128 | 0β255 | All bulbs reset to this level when MANUAL mode is entered. |
| Variable | Value | Range | Description |
| β | β | β | β |
| MIDI_CHANNEL | 15 | 1β16 | Channel the controller listens on. |
| NOTE_LIGHT[4] | 60, 61, 62, 63 | 0β127 each | Note numbers that turn bulbs 1β4 on/off. |
| NOTE_MIN_BRIGHT | 40 | 0β255 | Brightness of a note played at the softest velocity. |
| CC_LIGHT[4] | 22, 23, 24, 25 | 0β127 each | CC numbers that set bulbs 1β4 brightness. |
| CC_ALL_BRIGHT | 27 | 0β127 | CC number that sets all bulbs at once. |
| Variable | Value | Range | Description |
| β | β | β | β |
| NUM_PIXELS | 8 | 1β~60 | Number of LEDs on the strip; set to match yours. |
| STRIP_BRIGHTNESS_DEFAULT | 60 | 0β255 | Indicator brightness at boot (live-adjustable via the MANUAL STRIP target). |
| STRIP_BRIGHTNESS_MIN | 5 | 0β60 | Floor for the STRIP brightness control so the indicator stays visible. |
| COLOR_WARM | (255,130,15) | any RGB | MANUAL-mode strip color (set in setup()). |
| COLOR_RED | (255,0,0) | any RGB | ANIMATION-mode strip color (set in setup()). |
| MANUAL_BRIGHT_SHOW_MS | 1200 | 500β3000 | How long the brightness bar shows after a turn before reverting. |
| Variable | Value | Range | Description |
| β | β | β | β |
| ANIM_BPM_MIN | 20 | 5β120 | Free-run speed (BPM) at encoder fully left. One beat = one step / one cycle. |
| ANIM_BPM_MAX | 250 | 120β600 | Free-run speed (BPM) at encoder fully right. The knob is linear in BPM. |
| TAIL_SHIFT | 2 | 1β4 | Comet/larson/twinkle tail fade: b -= b >> this (smaller = longer tail). |
| CLOCK_TIMEOUT_MS | 600 | 300β2000 | Clock is treated as absent (β free speed) after this gap. |
| CLOCK_BLINK_MS | 90 | 30β250 | How long the purple clock indicator stays bright on each beat. |
Beat-lock subdivisions are fixed in SUBDIV_BEATS (1 bar, 1/2, 1/4, 1/8, 1/16).
lunt_cv.ino
is an alternate firmware for Lunt with a control-voltage input. The switchβs ANIMATION
position becomes CV mode: all four bulbs follow an incoming CV, e.g. an envelope
follower on a drum mic, so the lights pulse with the hits. MANUAL mode is the same as
above, except the TEMPO / SUBDIV targets are gone (there are no clock indicators), so
the encoder press cycles ALL β 1 β 2 β 3 β 4 β STRIP.
| Jack | Arduino pin | Notes |
|---|---|---|
| Ring | A2 | CV in, 0β5 V (the ZOIA sends CV on the ring) |
| Sleeve | GND | Β |
| Tip | β | not connected |
Use a TRS cable: a TS (mono) cable shorts the ring to ground.
| Control | Action | | β | β | | Turn encoder | Adjust the selected setting (right = more) | | Press encoder | Toggle the setting: FLOOR (orange bar) β SENS (blue bar) |
The strip shows a live red meter of the CV level: the leftmost pixel alone means silence (below the noise gate), and the full strip means full brightness. While you turn or press the encoder it briefly shows the selected settingβs bar instead. MIDI notes/CC are ignored in CV mode. FLOOR and SENS are kept across mode switches but reset on power-up.
Calibrating: play a hard hit and turn SENS up until the meter just reaches the right
end. If the second pixel flickers with no one playing, raise CV_NOISE_GATE.
| Variable | Value | Range | Description |
| β | β | β | β |
| CV_MODE_LEVEL | LOW | LOW / HIGH | Switch level that selects CV mode. |
| SWITCH_DEBOUNCE_MS | 50 | 20β200 | The mode switch must hold a level this long before the mode changes (rejects noise from the dimmer). |
| CV_NOISE_GATE | 20 | 0β100 | Readings at or below this (~0.1 V) count as silence (bulbs at FLOOR). |
| CV_FLOOR_DEFAULT | 40 | 0β160 | FLOOR at power-up. |
| CV_FLOOR_MAX / CV_FLOOR_STEP | 160 / 4 | β | FLOOR limit and change per detent. |
| CV_FULL_DEFAULT | 1023 | 102β1023 | SENS at power-up: the reading that gives full brightness (1023 = 5 V). |
| CV_FULL_MIN / CV_FULL_STEP | 102 / 32 | β | Most sensitive SENS (~0.5 V) and change per detent (~0.16 V). |
| CV_BRIGHT_MAX | 255 | 0β255 | Bulb brightness at full CV. |
| CV_UPDATE_MS | 2 | 1β10 | How often the CV is read and the bulbs updated. |
| CV_METER_REFRESH_MS | 40 | 20β100 | Minimum time between meter redraws (each strip refresh briefly pauses the dimmer timing). |
multiple definition of 'std::nothrow'The full error looks like new.cpp.o ... multiple definition of 'std::nothrow' ...
ArduinoSTL/new_handler.cpp.o ... first defined here.
Cause: the Dimmable Light library depends on ArduinoSTL, which redefines
operator new / std::nothrow already provided by the Arduino AVR Boards core
1.8.4 and newer, so the linker sees two definitions.
Fix: downgrade the core to 1.8.3, the last version that links cleanly with ArduinoSTL: Tools β Board β Boards Manager β search βArduino AVR Boardsβ β pick version 1.8.3 β Install. Re-select the Nano afterwards and recompile.
avrdude: stk500_recv(): programmer is not respondingCause #1 β the MIDI input is on RX. MIDI uses the Nanoβs hardware serial (D0/D1), the same UART the bootloader uses to receive the program. If the MIDI input circuit is connected to RX (D0), it blocks the upload. Fix: disconnect whatever is wired to D0 (RX) before uploading, then reconnect it afterward. (This is inherent to using hardware serial for MIDI β youβll do it every flash.)
Cause #2 β wrong bootloader. Most CH340-based Nano clones ship with the old bootloader. Fix: select Tools β Processor β ATmega328P (Old Bootloader) and upload again.
Also check the Serial Monitor is closed (it holds the port) and that the correct CH340/USB-serial port is selected.
Mechanical rotary encoders bounce, and EMI from the nearby AC dimmer makes it worse. The sketch already decodes the encoder with a quadrature state table that rejects bounce. If it still twitches, add a 100 nF capacitor from each encoder pin (CLK, DT) to GND for hardware debouncing.
Flip the right test in handleEncoder() to reverse the knob direction; the stripβs
left/right mapping is in fillPixels() / lightOnePixel().
First check the clock indicator: enter an animation (ANIMATION mode β press the encoder) and watch the far-right pixel β it turns purple and flashes on the beat when a clock is arriving. If it stays blue (or dark):
If the indicator is purple but tempo seems to do nothing: make sure youβve entered an animation (pressed the encoder), since the clock only drives a running animation, and that youβre watching a tempo-sensitive one (e.g. comet or 6/8 pulse).