Skip to main content
The following examples demonstrate common patterns for LispBM scripting on VESC. Each example is a complete, runnable script unless otherwise noted. Copy them into the VESC Tool scripting editor and upload to try them out.
VESC Tool ships with a built-in collection of example scripts accessible from the scripting editor menu. These examples are a good starting point for many common tasks.

Simple loop with status printing

The most basic VESC script structure: an initialization block followed by an infinite loop that periodically prints status and resets the motor timeout.

Blinking AUX output

Toggle the AUX1 output on and off at 1 Hz. This is the VESC equivalent of a “blink LED” example.

Reading motor RPM and reacting

Read the motor RPM and apply different behavior depending on the speed.

Controlling motor speed with set-duty

Ramp the motor duty cycle from 0 to 30% over 3 seconds, hold it, then brake.
Always call (timeout-reset) at least once per second whenever the motor is running from a script. If the script stops calling it — for example due to a crash — the motor will automatically stop after the timeout period configured in App Settings → General.

RPM control with soft start

Use set-rpm to drive a motor to a target speed, reading configuration to stay within safe limits.

Reading configuration values

Inspect key motor configuration parameters at startup. Useful for debugging or adapting script behavior to the configured hardware.

IMU tilt detection

Read the IMU roll angle and print a warning when the board tilts beyond a threshold.

CAN bus communication

Sending a raw CAN frame

Reading motor state from another VESC over CAN

Use can-cmd to execute a LispBM expression on a remote VESC and return the result:

Listing CAN devices

Receiving CAN frames with events

Enable events to receive CAN frames asynchronously without polling:

Motor fault monitoring

Check for faults and print them to the console:

EEPROM: persisting a value across reboots

Store a trip counter in EEPROM so it survives power cycles:

Spawning a background monitoring thread

Run motor control in the main thread and monitor temperature in a background thread: