Learn

A DIY stream deck and camera slider with Arduino

Advanced

Or see every lesson.

  • 261parts on the bench
  • 31boards running now
  • 1.00xreal time, on every board
Nano: a camera sliderlive0.000 s 0.00x
Press Run, click the end switch, then press GO
Click the end switch to home, then press GO. Turn the ease knob and run it again.

People who stream and make videos build a surprising amount of their own gear. Two builds come up again and again: a button box with labels for scene changes and mute, and a motorized camera slider for smooth, slow shots and timelapses. Both are good first projects with a microcontroller because the parts are cheap and the result is something you use every day.

The circuit above is a camera slider on an Arduino Nano in Mokxi: a NEMA 17 stepper on an A4988 driver, an end switch to home against, knobs for the move time and the ease, a GO button, a mode switch and a shutter output. Press Run, click the end switch, and press GO. A second built-in, the stream deck, puts six keys and their labels on a Pro Micro with an OLED screen.

What is not simulated, up front: there is no camera in the slider circuit and no PC on the stream deck’s USB. The slider’s shutter line lights an LED where a real rig drives an optocoupler, and the stream deck prints each hotkey as a [Keyboard] line on the Serial Monitor. The motion, the timing, the screen and the keys all run for real.

Want the step-by-step version? The lesson "Build a camera slider" walks through this with checkpoints.

Open the lesson

A stream deck with labels

A plain macro pad makes you remember which key does what. The stream deck built-in draws a label over each key on a 128 by 64 OLED, lights the one you press, and uses the sixth key to flip to a second page of five more actions. The screen is an SSD1306 on I2C, which on a Pro Micro is pins 2 and 3.

Each action sends Ctrl and Shift with an F-key from F13 to F22 through Keyboard.h. Almost no program uses F13 and above on its own, so streaming software can take them as hotkeys without clashing with anything: press the key once in a program’s hotkey box, such as the hotkey settings in OBS Studio, and it learns it. The labels, the keys and the modifiers are all in the sketch’s config block.

Homing a stepper

A stepper motor has no idea where it is when it powers up. It only counts the steps it is told to take. So a slider starts by driving the carriage slowly toward one end until it presses an end switch, and calls that zero. From then on it knows its position to the step. If the switch never closes, the example stops after a whole rail of steps rather than grinding into the end.

The A4988 needs just two signals: DIR for the direction and one pulse on STEP for each step. A GT2 belt on a 20-tooth pulley moves 40 mm a turn, so a 200-step motor in full steps is 5 steps per millimeter. The example runs full steps so the simulation is quick; a real slider usually uses 1/16 microstepping for smoother video and multiplies the steps per millimeter by 16.

Ease in and ease out

A move that starts at full speed jerks the camera, and the jerk shows in the footage. So the carriage speeds up evenly, cruises, and slows evenly for as long at the end: a trapezoid of speed, the same shape the AccelStepper library’s acceleration produces. The ease knob sets how much of the move is spent ramping, from none to half each way.

The sketch does not set a speed at all. Every pass through its loop it works out where the carriage should be at this moment, from the fraction of the move time gone, and steps once toward it. The top speed has a limit: with the most ease the peak is twice the average, and a stepper asked for more steps a second than it can follow skips them, so the shortest move time is chosen to stay inside what the motor follows.

Where the carriage should be, from the example sketch
long u = t * 1000 / ms;                         // time gone, in thousandths
long want = start + distance * eased(u, ease) / 10000;
if (position < want) stepOnce(true);
else if (position > want) stepOnce(false);

The config block

Both sketches put everything you would change at the top, under Make it yours. On the slider that is the pins, STEPS_PER_MM and RAIL_MM for your rail, the range of the move time knob, which way the end switch is, and the timelapse settings. On the stream deck it is the key pins, the labels for both pages, the hotkeys and the modifiers held with them. Change a number, press Run, and watch what it does before you change the real rig.

Timelapse: move, settle, shoot

Slide the mode switch and the slider shoots a timelapse instead: it divides the rail into equal moves, and after each one waits for the rig to stop shaking before it fires the shutter. A long exposure taken while the rail still rings is blurred. SHOTS, SETTLE_MS and SHUTTER_MS are in the config block.

On a real rig the shutter output drives an optocoupler wired across the shutter contacts of the camera’s wired remote socket, so the camera’s circuit and the Arduino’s never touch. Many cameras want focus closed with shutter, which is a second optocoupler.

Questions

Does the stream deck work with OBS?

On a real Pro Micro it types Ctrl+Shift+F13 to F22, which you can assign as hotkeys in OBS Studio or other software. In Mokxi the keys print as [Keyboard] lines instead, since USB is not simulated.

Which stepper driver do DIY camera sliders use?

The A4988 and similar step-and-direction drivers are common, with a NEMA 17 motor and a GT2 belt. The example uses an A4988 in full steps; set 1/16 on a real rig for smoother motion.

Can Mokxi trigger my camera?

No. The shutter output lights an LED in the simulator. On a real slider it drives an optocoupler across your camera’s remote socket.

Is there a course?

Yes. Build a camera slider is three short lessons: homing a stepper, the eased move, and timelapse.

Build this for real

Open the editor, change a value and watch the number move with it. Nothing to install, and no account needed.