Introduction to Trinket M0

Trinket M0 is a microcontroller who can work with python (specifically circuit-python), like Raspberry Pi, so it is easier for us to handle it.

We will make a circuit with LED’s which can be put on a christmas tree.

We make the following circuit.

We put two same-colour LED’s (eg red) with their positive terminal on trinket pin 1 and their negative one on the terminal of a 100 Ohm resistor.

We do the same with two other LED’s, same-colour, but different with the previous ones (eg blue), with their positive terminal on pin 2 and their negative one on the terminal of another 100 Ohm resistor.

The rest resistors terminal is connected with trinket ground.

We connect our trinket with our computer via a USB cable.

We launch Mu Editor. Details you may find in the end of the lesson.

We create a file “” and we write the code which can be found in the end of this lesson. On this phase, you do not need to know exactly what it does. It just prepares the trinket to behave just like Raspberry Pi in our previous lessons.

We save the file in the lib folder.

We create a new file “”.

As in the previous lessons we write this code to make the LED’s blink.

from mygpiozero import LED
from time import sleep

myled1 = LED(1)
myled2 = LED(2)

while True:

We save the file in the trinket root folder.

After this activity, the LED’s should begin blinking.

We can disconnect the trinket from the computer, by connecting it to batteries. We choose 3 1.5V batteries and we connect them to trinket “Bat” pin and the ground.

We put the LED’s on a tree. It can be a little one we bought or a christmas card we created.

Information about Mu Editor

We can write code on Trinket M0 with various editors, but the recommended way by Adafruit is Mu Editor.

You will find it  here.

Code for

import board
import digitalio

mymapping = [board.A0, board.D2]

class LED():
    def __init__(self, pin):
        self.led = digitalio.DigitalInOut(mymapping[pin-1])
        self.led.direction = digitalio.Direction.OUTPUT
    def on(self):
        self.led.value = True
    def off(self):
        self.led.value = False


mygpiozero module is explicitly declared that it is not associated with the original python module gpiozero. It was created only for educational reasons, so that the ninjas could repeat the same commands on the controller.

Alexandros Zeakis helped me on handling problems I had when creating the code. This lesson would not be possible without him and I thank him.