Generative art with Processing and working with Circuit Playground Express

whykay

whykay 👩đŸģ‍đŸ’ģ🐈đŸŗī¸â€đŸŒˆ (she/her)

Posted on July 15, 2020

Generative art with Processing and working with Circuit Playground Express
Note: This is an old post of a WIP project originally posted on Coding Grace - for this post in dev.to, I'm splitting it up into a series.

This might end up being a multi-part post. It's my learning journey of fails and little delights (or bigger if I'm successful) on learning about generating art via Processing from data obtained from the accelerometer from the Circuit Playground Express.

Components mentioned in this project

Software references

Day 1: PyProcessing, Circuit Python, E-ink Gizmo - lots of experimenting

Ok, what I wanted to do (which made sense in my head) was to create an image with Processing when it detects sensor changes in CPX.

I was thinking of going whole hog with Python as there's a Python library for Processing via py.processing.org but first off I need to get Processing installed on my Raspberry Pi (model 4 on pi-top[4]). I quickly realised the normally version via Processing site doesn't work, but there's a pi.processing.org that has a version of Processing specific for it.

Hit download and untarred it and voila, it worked.

Spent some time going through the tutorials with Python on Processing. That was fun... now I want to get cracking on how to get it working with CPX.

I can get Circuit Python to print to the E-ink Gizmo screen with the text Testing. That's a good start. 😊

Alt Text

Was looking at using command line to call it programmatically... not so straight forward because it specifically needs a really old version of Java... and it doesn't support OpenJDK and just ugh...

Anyway, maybe it wouldn't be so bad to play with Processing, it's only Java light, right. I found that it does interact with GPIO on the Raspberry Pi, so that's a positive.

ℹī¸ Reference

But I want it to work with CPX. I'll be connecting it with a microUSB cable to the Raspberry Pi (which I'm VNC'd into). So playing with GPIO is a moot point.

Ok, there's too many moving parts here that don't necessarily talk to each other, let's roll back a little. What comes out of the box with Python that can generate images? It's Python Turtle. I kind of ignored it as I was teaching kids about Python with it late last year, but I do notice a lot of people create generative art with Python Turtle.

The next question is how to save the output of Python Turtle.

Internetz helped here, between:-

I can see that you can generate something simple, save it to an image (note, I had to install pillow to use PIL), and also close the Python Turtle window after it generates the image.

ℹī¸ Reference https://python-pillow.org/

So it's back to Circuit Python after all that. Interesting exercise though.


Ok, back to basics

CPX with E-ink Gizmo -> pi-top[4] with Raspberry Pi Model 4

Remembering how to access the accelerometer data thanks to the following:

Adafruit Libaries:

  • adafruit_display_text
  • adafruit_gizmo
  • adafruit_il0373.mpy

Found the following error:

Group Full RunTimeError for label.py: text was too long
Enter fullscreen mode Exit fullscreen mode
ℹī¸ Reference: https://github.com/adafruit/Adafruit_CircuitPython_Display_Text/issues/11

Also realising waiting 180s is very boring!

💖 đŸ’Ē 🙅 🚩

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related