Circuit Python + Adafruit Trinket M0 + BiColor 8x8

May 24, 2018

Circuit Python + Adafruit Trinket M0 + BiColor 8x8

I've been programming in Python for quite a while but have only dabbled in MicroPython.  Today I decided to take a Trinket M0 for a test drive and check out Adafruit's version of MicroPython:  CircuitPython!  

I had an 8x8 Adafruit Bicolor LED Square Pixel Matrix sitting on my desk, and thought it would be fun first CircuitPython project.

It is just unbelievably easy to get up and running with CircuitPython on the Trinket  M0.  Adafruit has a great guide to get you started, but I will share a few highlights.

  • Updating your Trinket M0 to the latest firmware is always a good place to start
  • Make sure you install the latest version of the Mu editor, which makes working in CircuitPython a breeze.  If you have an old version of Mu, be sure to delete it.  In my case, I had an older version of Mu that was setup only for a Micro:Bit.  In the latest version, you can select what flavor of MicroPython you wish to use (Circuit Python, MicroBit, or Python 3)
  • It is always good to start by installing some example code...the proverbial "make the light blink"  I always tell people, once you get the light to blink, you can do anything.  

The neat thing about the Trinket M0 is that the device shows up as a disk on your machine.  So you can add/remove files directly on the device.  One slight downside with the Trinket M0 is that it does not have a lot of memory on it, so you should plan on deleting any libraries you don't need.  In this case, we deleted the NeoPixel library since we would not be using it.

Adafruit has a bundle of libraries for CircuitPython already compiled.  I was quite pleased to find a HT16K33 library has been built, which made my project quite simple.  To run this library, I also needed to instal the Adafruit_Bus_Device library.  You just copy the directories from the bundle that you need into /lib on your Trinket M0.  If there isn't enough space, simply delete any libraries you are not using.  You can also delete the README.txt file and the Windows 7 driver (if you are on a Mac or Linux machine).

Once I had the files on the device, I found some example code on Adafruit's GitHub page.  With the Bicolor matrix, I simply had to uncomment the line for matrix.Matrix8x8x2 

 

Now comes the fun part!  I simply saved the code I created as "code.py" in the root directory of the Trinket M0 and it executed right away!

The example code was cool, but I thought a smiley face would be even better

To create this, I needed to know which locations on the matrix to light up.  A handy way to do this is in Excel or Google Sheets:

So now I know I need to light up (0,1) (0,2) (1,1) (1,2), etc...

And here is the result!  Note that the 3rd number in each line denotes the color: green is 1, red is 2.

 

 




Leave a comment

Comments will be approved before showing up.


Also in News

The Raspberry Pi Pico
The Raspberry Pi Pico

July 28, 2021

Raspberry Pi Pico’s are a great microcontroller that has a fair amount of range, despite the slightly more tricky set up process, once it’s ready to go there’s a lot you can do. 

Continue Reading

Raspberry Pi Troubleshooting

June 30, 2021

Continue Reading

An introduction to soldering
An introduction to soldering

June 08, 2021

Soldering is a good skill to learn and improve throughout your making and DIY-ing, there’s quite a few situations where it will be the best option for a more permanent build.

Continue Reading