Facebook Pixel Learn Lisp Programming Using MCUs - Part 2: Extending µLisp with Custom Functions | Circuit Cellar - education - Les denne historien på Magzter.com

Prøve GULL - Gratis

Learn Lisp Programming Using MCUs - Part 2: Extending µLisp with Custom Functions

Circuit Cellar

|

February 2025

In the second installment of this series, Raul delves into the world of µLisp and shows how to extend capabilities by adding custom functions such as "pulsein" and "servo-create", enabling developers to interface with ultrasonic sensors and control servomotors. In Part 1, Raul presented µLisp concepts and syntax, and extensions specific to MCUs.

- Raul Alvarez-Torrico

Learn Lisp Programming Using MCUs - Part 2: Extending µLisp with Custom Functions

μLisp is a dialect of the Lisp programming language. It is tailored to microcontrollers having limited amounts of RAM, and can be run on various platforms—from the Arduino Uno based on the ATmega328, up to the Teensy 4.0/4.1 [1]. To follow the topics discussed here, you need to be acquainted with the Arduino platform and any programming language from the Lisp family. Please see Part 1 of this article series (“Crash Course Offers Insight into Pioneering Language,” Circuit Cellar 411, October, 2024) for a brief introduction to Lisp programming and the µLisp dialect [2].

With µLisp, it is possible to add your own extension functions, such that they appear as built into the language after re-compiling and flashing the µLisp interpreter to your Arduino board. There’s an excellent tutorial on how to do this on the µLisp website [3]. I will build on that tutorial to discuss how to add custom functions. For the examples presented here, I will continue to use Seeed Studio’s Wio Terminal MCU development board; but the information discussed also can be applied to other µLisp-supported Arduino boards.

EXTENDING µLISP

In general, any function not supported by default in µLisp can possibly be added as an extension to the language—for instance, hardware access functions for servomotor control. Let’s explore a simple example to help us understand how the language extension system works.

Listing 1 shows the Arduino C code for adding the pulsein extension to µLisp, which is not available by default. This extension will make it possible to measure digital pulse widths. Five sections of the listing show the µLisp extensions structure. Like the core µLisp interpreter, extensions are also written in Arduino C language. So, any extensions to the interpreter imply basically writing C code. That makes adding them straightforward, using the Arduino C language built-in functions and external libraries.

FLERE HISTORIER FRA Circuit Cellar

Circuit Cellar

Circuit Cellar

IDES Converge Toward VS Code

Your Next IDE Might Look Very Familiar

time to read

12 mins

April 2026

Circuit Cellar

Circuit Cellar

New KYOCERA AVX Capacitors for Optical Communications

KYOCERA AVX, a leading global manufacturer of advanced electronic components engineered to accelerate technological innovation and build a better future, has expanded its selection of 550/560 Series ultra-broadband capacitors to better satisfy surging cross-market demand for high-speed, high-bandwidth optical communication systems.

time to read

2 mins

April 2026

Circuit Cellar

Circuit Cellar

Wireless Convergence Reshaping Autonomous Transportation

The future of transportation will not be defined by a single technology milestone.

time to read

4 mins

April 2026

Circuit Cellar

Circuit Cellar

STMicroelectronics' New STM32 Series Redefines Entry-Level Microcontroller Performance and Value for Smart Devices Everywhere

STMicroelectronics (ST), a global semiconductor leader serving customers across the spectrum of electronics applications, has announced a new generation of entry-level microcontrollers (MCUs) to boost the performance of billions of tiny smart devices throughout factories, homes, cities, and infrastructures while meeting cost, size, and power limitations.

time to read

1 min

April 2026

Circuit Cellar

Circuit Cellar

Datasheet: Haptic Components Things That Go Buzz in the App

Haptic Devices Bring Physical Feedback to the Human Interface

time to read

7 mins

April 2026

Circuit Cellar

Circuit Cellar

Software-Defined Systems

Reshaping the Future of Modern Cars

time to read

7 mins

April 2026

Circuit Cellar

Circuit Cellar

Vishay Intertechnology Phototransistor Optocouplers Deliver Accuracy and Energy Efficiency for Industrial Applications

Vishay Intertechnology, Inc. introduced a new series of phototransistor optocouplers that combine a high and linear current transfer ratio (CTR) over temperature with a low forward current of 0.5mA.

time to read

1 mins

April 2026

Circuit Cellar

Circuit Cellar

B MCU Real-Time Tracing

How to Trace MCU Code in (Almost) Real Time

time to read

13 mins

April 2026

Circuit Cellar

Circuit Cellar

Getting Started with Zephyr RTOS

Sometimes, too much can be just enough. In this article, Jacob shows why learning an RTOS that's more than you need can be just what you need for your growing skillset.

time to read

8 mins

April 2026

Circuit Cellar

Circuit Cellar

A Tribute to Robert Tinney

A Captivating Artist in the Early Days of Circuit Cellar

time to read

3 mins

April 2026

Listen

Translate

Share

-
+

Change font size