Adafruit M0 boards

The Adafruit Gemma M0, Adafruit ItsyBitsy M0, and Adafruit Feather M0 Adalogger are each based on the ARM Cortex M0+ CPU with a 48 MHz clock, but with different physical form factors.

Each board provides 256 KB flash and 32 KB RAM. The ItsyBitsy and Feather boards also include a separate 2 MB SPI DataFlash chip which is used by uLisp to allow you to save the Lisp image using (save-image).

These boards all have similar performance when running uLisp; for example, they run the Tak benchmark in 14 secs; see Performance.

Install the ARM version of uLisp for use with these boards.

Adafruit Gemma M0

The Adafruit Gemma M0 [1] is about the same size as a 50 pence piece, and is the smallest board that can run uLisp. It has a limited selection of pins, but you can connect to them using alligator clip leads, making it ideal for students:

GemmaM0.jpg

It includes a JST connector to allow you to power it from a Lipo battery.

I/O pins

Apart from the power pins it provides three multi-purpose pins:

Label Functions
D0/A2 Digital I/O, analogue input, PWM, SDA, RX. 
D1/A0 Digital I/O, analogue input, DAC output.
D2/A1 Digital I/O, analogue input, PWM, SCL, TX.

LED

The Adafruit Gemma M0 has a red LED connected to the digital pin 13 which you can flash with the following program:

(defun blink (&optional x)
  (pinmode 13 t)
  (digitalwrite 13 x)
  (delay 1000)
  (blink (not x)))

Run it by typing:

(blink)

Exit from the program by entering ~.

DotStar RGB LED

The Adafruit Gemma M0 also has a DotStar (APA102) RGB LED mounted on the board. For more information about DotStar LEDs see Driving DotStar RGB LEDs.

Here's a program to set the LED to an arbitrary colour and brightness:

First we define variables for the clock and data pins; on the Gemma these are connected to Arduino pins 3 (data) and 4 (clock):

(defvar data 3)
(defvar clk 4)

Here's a routine to send a byte to the display, MSB first, toggling the clock pin after each bit:

(defun send (byte)
  (dotimes (i 8)
    (digitalwrite clk 0)
    (digitalwrite data (logand (ash byte (- i 7)) 1))
    (digitalwrite clk 1)))

Finally here's the function to send the appropriate stream of bits to the LED to define its colour and brightness:

(defun dotstar (bri blue green red)
(pinmode clk t) (pinmode data t) (mapc send (list 0 0 0 0 (logior bri #xe0) blue green red #xff)))

To set the LED evaluate:

(dotstar bri blue green red)

where bri is the brightness (from 0 to 31), and blue, green, and red are the colour components, from 0 to 255. For example, this sets the LED to magenta (blue+red) at low brightness:

(dotstar 1 255 0 255)

Adafruit ItsyBitsy M0

The Adafruit ItsyBitsy M0 [2] is the same size as Adafruit's other ItsyBitsy boards.

ItsyBitsyM0.jpg

LEDs

The Adafruit ItsyBitsy M0 also has a red LED connected to the digital pin 13 which you can flash with the following program:

(defun blink (&optional x)
  (pinmode 13 t)
  (digitalwrite 13 x)
  (delay 1000)
  (blink (not x)))

Run it by typing:

(blink)

Pin 13 can also be used as an analogue pin, so you can pulsate the red LED slowly on and off with the program:

(defun pulse ()
  (let (down)
    (loop
     (dotimes (x 256) 
       (delay 5) 
       (analogwrite 13 (if down (- 255 x) x)))
     (setq down (not down)))))

Run it by typing:

(pulse)

Exit from either program by entering ~.

DotStar RGB LED

The Adafruit ItsyBitsy M0 has a DotStar (APA102) RGB LED mounted on the board. For more information about DotStar LEDs see Driving DotStar RGB LEDs.

Here's a program to set the LED to an arbitrary colour and brightness:

First we define variables for the clock and data pins; these are connected to Arduino pins 40 (clock) and 41 (data):

(defvar clk 40)
(defvar data 41)

Here's a routine to send a byte to the display, MSB first, toggling the clock pin after each bit:

(defun send (byte)
  (dotimes (i 8)
    (digitalwrite clk 0)
    (digitalwrite data (logand (ash byte (- i 7)) 1))
    (digitalwrite clk 1)))

Finally here's the function to send the appropriate stream of bits to the LED to define its colour and brightness:

(defun dotstar (bri blue green red)
(pinmode clk t) (pinmode data t) (mapc send (list 0 0 0 0 (logior bri #xe0) blue green red #xff)))

To set the LED evaluate:

(dotstar bri blue green red)

where bri is the brightness (from 0 to 31), and blue, green, and red are the colour components, from 0 to 255. For example, this sets the LED to magenta (blue+red) at low brightness:

(dotstar 1 255 0 255)

Adafruit Feather M4 Adalogger

The Adafruit Feather M4 Adalogger [3] is the same size as Adafruit's Feather range of boards, with its own family of matching shields. It includes an SD Card socket which can be used by uLisp:

FeatherM0.jpg

LED

The Adafruit Feather M0 has a red LED connected to digital pin 13 and a green LED connected to pin 8 which you can flash with the following program:

(defun blink (pin &optional x)
  (pinmode pin t)
  (digitalwrite pin x)
  (delay 1000)
  (blink pin (not x)))

To flash the green LED run:

(blink 8)

These pins can also be used as analogue pins, so you can pulsate the red LED slowly on and off with the program:

(defun pulse ()
  (let (down)
    (loop
     (dotimes (x 256) 
       (delay 5) 
       (analogwrite 13 (if down (- 255 x) x)))
     (setq down (not down)))))

Run it by typing:

(pulse)

Exit from either program by entering ~.


  1. ^ Adafruit Gemma M0 on Adafruit.
  2. ^ Adafruit ItsyBitsy M0 Express on Adafruit.
  3. ^ Adafruit Feather M0 Adalogger on Adafruit.