Build a Talking Baby Groot Using Circuit Playground Express

John Gallaugher
5 min readSep 10, 2018

--

Capacitive Touch on the Circuit Playground Express allows an alligator clip attached to Baby Groot’s Leaves to receive a “touch” signal when the leaves are touched.

Difficulty Level : Easy

Materials:

Circuit Playground Express (CPX): I suggest buying the $29.95 Base Kit, as it comes with a USB Mini to Standard USB cable that you’ll need to program your Circuit Playground Express, plus it also comes with a battery pack & batteries: https://www.adafruit.com/product/3517

A single test-lead alligator clip (it’s a wire with an alligator clip at each end). You can get a bunch of them inexpensively online — Adafruit sells a dozen for $3.95: https://www.adafruit.com/product/1008

Baby Groot Flower Pot (I got mine for $5.95 on Amazon): https://www.amazon.com/dp/B0796BGY8M/ref=cm_sw_r_tw_dp_U_x_U-SLBbR9N9BJ3

A living plant: Mine is called “syngonium”. I bought it at a Star Market Supermarket in Chestnut Hill, MA for less than $10. I’m sure you could use some other conductive material, as well, but hey, Groot — you need a real plant.

Installing CircuitPython on your Circuit Playground Express (CPX)

Important things to note:

Even if you don’t want to write code in python for your CPX, you will have set up the CPX to run Circuit Python. This is described in more detail at:

https://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-quickstart

and involves these steps:

  • download the latest CPX CircuitPython uf2 file from the link/button you’ll find at the URL above.
  • connect your CPX to your USB cable, and your USB cable to your computer.
  • press the “Reset” button on the CPX so that your CPX lights turn green, this indicates that your CPX is able to accept files.
  • drag the .uf2 file that you downloaded above into the CPLAYBOOT drive that shows up on your computer. CPLAYBOOT should appear the same way a USB drive shows up when you plug a USB stick into your computer’s USB port.
  • After dragging over the .uf2 file, CPLAYBOOT’s name will change to CIRCUITPY. That’s it — you’re ready to upload python code!

Also: Once you’ve set a CPX to run CircuitPython, it will not be able to run MakeCode until you’ve updated the bootloader for MakeCode. More details are provided by Adafruit at: https://learn.adafruit.com/adafruit-circuit-playground-express/adafruit2-uf2-bootloader-details#updating-the-bootloader

Downloading the Files

You can download the files (the code.py python file, and the four “I_am_groot_#.wav” files from GitHub, here: https://github.com/gallaugher/baby-groot

If you’ve never done this before:

  • Visit the URL above
  • Click the “Clone or Download” green button to the right.
  • Select “Download Zip” to save a .zip file to your computer. You computer should now have a file named: baby-groot-master.zip
  • Double click this .zip file to extract its contents.

This should create a folder named “baby-groot-master”. You now have the files you’ll need!

Putting These Files on your CPX

Now prepare your Circuit Playground Express to receive these files:

  • connect your CPX to your USB cable, and your USB cable to your computer.
  • press the “Reset” button on the CPX so that your CPX lights turn green, this indicates that your CPX is able to accept files.

And copy all four files to the CPX:

  • Open the folder “baby-groot-master” and drag over all five files: code.py (which is the python code that controls your CPX), and four I_am_groot_#.wav files, numbered 1–4.

You should hear your CPX say “I am groot” in Baby Groot’s Voice. This indicates that your code is running!

Hooking Things Up

The code assumes that you have an alligator clip attached to the circular pad on your CPX that is labeled A1, so:

  • Attach one end of your alligator clip to the CPX
  • Attach the other end to some stems in Baby Groot’s leaves.

My plant is nicely dense, so touching one leaf will carry a signal to any touching leaves, and eventually get to the cable, then get back to the CPX via the alligator clips & sensor ring A1.

Now when you touch Baby Groot, he should say “I am Groot” when you move your hand off of his leaves.

The Code

If you want to modify the code, you’ll need an editor. Adafruit recommends that you use the Mu editor, which works great with CircuitPython: To install Circuit Python and the Mu editor on your computer, see the instructions at: https://learn.adafruit.com/adafruit-circuit-playground-express/what-is-circuitpython

I originally tried this in MakeCode (makecode.adafruit.com), which offers block programming as well as JavaScript, but when I hooked an alligator clip to one of the copper touchpads on the CPX, it constantly registered a “touch”, even when nothing seemed to be touching the other clip. I tried readjusting the connection and still had a constant touch registering (those surrounding my office were very tolerant as hundreds of “I am Groot” sounds came from my tinkering). I’m *very* new at this, and there is likely a way to adjust sensitivity in MakeCode / JavaScript, but I went straight for CircuitPython. Do feel free to make suggestions or enlighten me to things I should have considered.

The python code is pretty simple. I teach Swift/iOS development, but don’t really know python. Looking at some sample code helped me put this together. You can find the code on GitHub and you can link directly to the python code via: https://github.com/gallaugher/baby-groot/blob/master/code.py

The comments at the top explain how I created the .wav files, and you should be able to use these tips if you wanted to create a similar project with different sounds.

I teach managers and app developers at Boston College. I’m on Twitter at @gallaugher. Want to learn to build iOS apps? My online offering assumes no prior programming experience, but brings students through eight apps, ending in a “Yelp-style” rating app that use Google SignIn and Google Cloud Firestore. Over 100 videos are perfect for use in a “flipped class” setting, but any student can follow along. The product is only $25, and the first three chapters (two apps) are free. Find the latest version at http://gallaugher.com/swift I also write a managerial textbook in use at over 300 universities. It’s also inexpensive (only $29 for the online version) and can be found at http://gallaugher.com/book

--

--

John Gallaugher
John Gallaugher

Written by John Gallaugher

Boston College Prof. Tech/Business. YouTube.com/profgallaugher Advises student entrepreneurs, TechTreks (S.Valley/SEA/BOS/NY,/Ghana). Book gallaugher.com/book

No responses yet