Link Search Menu Expand Document (external link)

Lesson 1: Intro to the CPX

Table of Contents

  1. Hardware
    1. Built-in Input
    2. Built-in Output
  2. Input/Output (I/O)
    1. Input/Output (I/O) Pads
    2. Analog Input
    3. Capacitive Touch Sensor Pads
    4. Power Pads
    5. CPX Microcontroller
  3. Using the CPX as Computer Input
  4. Programming
    1. MakeCode
  5. Learning Resources
    1. Example projects
  6. Next Lesson
  7. Educational reflections

Hand holding a Circuit Express Playground board Figure. The Circuit Express Playground. Image from Adafruit.

The Circuit Playground Express (CPX) is an introductory physical computing board created by Adafruit. It is a wonderful electronic prototyping platform board for learning electronics and programming and for creating imaginative physical computing projects (e.g., see samples here).

Compared with Arduino, the CPX’s advantages for novice makers are twofold:

  1. First, the CPX can be programmed with an easy-to-use drag-and-drop visual programming language called MakeCode developed by Microsoft, which is similar to Scratch. As students and makers gain experience and expertise, they can switch over to more advanced programming languages such as CircuitPython (Python), or Arduino (C/C++)

  2. Second, the CPX includes a variety of built-in inputs and outputs, so you do not need to purchase or wire-up external components (or even use a breadboard). On-board inputs include a LIS3DH accelerometer, a light-level sensor (a phototransistor), multiple push buttons, a microphone, and outputs include neopixel LEDS, a speaker, and infrared receivers/transmitters.

To contextualize CPX’s potential even further, we can use the three evaluation criteria for creative construction kits that Mitchell Resnick and Brian Silverman outline in their fantastic IDC’05 paper “Some Reflections on Designing Construction Kits for Kids”. Creative constructions kits should have:

  1. Low floors—kits should be approachable, easy-to-use for beginners;
  2. high ceilings—kits should grow with you as you learn and gain experience, allowing you to create increasingly advanced projects;
  3. and wide walls—kits should support a breadth of designs and projects.

We believe the CPX meets each of these criteria—making it a powerful prototyping and educational platform. As an example, at the University of Washington, the CPX has been used in our MHCI+D program as well as some introductory electrical engineering courses—quite the range of contexts!

Hardware

One key benefit of the CPX hardware—compared with vanilla Arduino boards like the Uno—is that it’s full of amazing input/output (IO) components. Adafruit provides a detailed “guided tour” but, in short, the board includes five types of input include motion, temperature, light, sound, and buttons as well as two types of output (LEDs, sound).

It’s OK if you don’t understand all of the terminology used below. In fact, if this is the first time you’ve ever played with electronics, we fully expect that this is mostly all new to you. Still, it’s worthwhile to skim over the sections below to get a sense of what’s possible with the CPX before we start building!

Built-in Input

Video. The CPX has lots of really fun and interesting on-board sensors, including an accelerometer, temperature, light, sound, and more. In the video above, I’m showing how to use the on-board accelerometer (motion sensor) to create a “motion mouse” with the CPX. See L7.2: Accelerometer Mouse for more!

Specifically, the CPX includes the following built-in input/sensors:

  • 1 x Motion sensor (LIS3DH triple-axis accelerometer with tap detection, free-fall detection)
  • 1 x Temperature sensor (thermistor)
  • 1 x Light sensor (phototransistor). Can also act as a color sensor and pulse sensor.
  • 1 x Sound sensor (MEMS microphone)
  • 2 x Push buttons, labeled A and B
  • 1 x Slide switch

An annotated diagram showing the location of the built-in motion, temperature, light, sound sensors along with the push buttons and slide switch

Figure. An annotated image of the CPX’s built-in sensors/input.

Built-in Output

In addition to the built-in input, the CPX also has built-in LEDs and speaker for light and sound output. More specifically:

  • 10 x mini NeoPixels, each one can display any color
  • 1 x Mini speaker with class D amplifier (7.5mm magnetic speaker/buzzer)
  • Green “ON” LED so you know its powered
  • Red “#13” LED for basic blinking

An annotated diagram showing the location of the built-in neopixels and speaker

Figure. An annotated image of the CPX’s built-in output.

Input/Output (I/O)

In addition to the built-in components, the CPX has 14 connection pads to support interfacing with external input/output (I/O), including buttons, LEDs, and more. You can use a variety of connection strategies from sewing with conductive thread to wire wrapping to even small metal screws, the most common connection is an alligator clip.

A pinout diagram of the CPX highlighting the 14 alligator pads

Figure. An annotated image of the CPX’s 14 alligator pads for power and GPIO.

Input/Output (I/O) Pads

The CPX has eight general purpose I/O pins (GPIO) for interfacing with external electronic components. All of the I/O pads can be used as digital I/O, analog input, and PWM.

Each pad can provide up to ~20mA of current so do not connect a motor or other high-power component directly. If you don’t know what this means, that’s OK! You can always ask the instruction team whether a component is safe to use!

A pinout diagram of the CPX highlighting the CPX GPIO pads

For more information, see Adafruit’s CPX Pinouts Guide.

Analog Input

Video. Pins A1-A7 on the CPX can be used for analog input to read voltages between 0-3.3V, which the CPX converts to a number between 0-1023. Here, I’m using a potentiometer, which dynamically changes its resistance (and splits the voltage levels) based on knob position. Learn more about analog input in L8: Analog Input!

The CPX has six pins that can read analog input (A1-A7). Analog input pins read voltage levels that range between 0V (GND) to 3.3V. The CPX converts these voltages to a number between 0-1023 using what’s called an analog-to-digital (ADC). The official CPX docs list the ADC as 12 bits (0-4096) but we’ve found that, in practice, it defaults to 10-bits. So, an analog signal is converted from 0 - 1023.

Below is the pinout diagram for the CPX highlighting the analog input pins (A1-A7):

A pinout diagram of the CPX highlighting the analog input pins

You’ll learn more about analog input in L8: Analog Input!

Capacitive Touch Sensor Pads

Video. Pins A1-A7 on the CPX can be used for capacitive touch sensing. Here, I’m showing how we can use a soda can to build a simple hand proximity detector. Learn more here!

Of the eight GPIO pins, seven can be used for capacitive touch sensing (Pins A1-A7). You’ll learn more about capacitive sensing in Lesson 5!

A pinout diagram of the CPX highlighting the capacitive touch pads

Power Pads

As the Adafruit CPX guide describes, there are six power pads equally spaced around the CPX’s perimeter. Specifically, there are:

  • 3 x GND pads, which are all connected together
  • 2 x 3.3V out pads
  • 1 x USB/battery Vout pad, which is a special power pad. This pin will supply either USB power (5V) or LiPoly power (3.7V). If both are connected, the CPX supplies the higher voltage. This output is not connected to the onboard regulator, so can supply up to 500mA continuous and 1A peak before tripping the internal fuse (if the fuse trips, just wait a minute and it will automatically reset)

A pinout diagram of the CPX highlighting the alligator power pads

Figure. An annotated image of the CPX’s GND and Vout power pads.

CPX Microcontroller

The CPX also has a powerful embedded microcontroller—the ATSAMD21 ARM Cortex M0 Processor—running at 3.3V and 48MHz. In comparison, the Arduino Uno is powered by a much older and slower microcontroller: the ATmega328P at 5V and 16 MHz.

Using the CPX as Computer Input

Video. The CPX can be used as an input controller to your computer. You can make your own keyboard, mouse, joystick, and more! This example is from Lesson 5.3: Making a Capacitive Keyboard.

Like the Arduino Leonardo, the CPX can act like a keyboard, mouse, joystick, MIDI, or simply a serial port. So you can easily make custom input to your computer—neat!

You can learn more about this in:

Programming

An additional benefit of the CPX compared with traditional Arduino is that it can be programmed multiple ways.

For novices with limited programming background or for those who simply like visual programming languages, you can use MakeCode. More advanced users may choose Python via CircuitPython or C/C++ via the Arduino IDE.

MakeCode

Microsoft’s MakeCode was designed to provide a visual, drag-and-drop interface for programming physical computing projects. This visual programming style—called block-based programming—was popularized by and is similar to Scratch. The video below shows how you program the CPX simply by dragging-and-dropping “puzzle pieces” (blocks).

Amazingly, you can also test your program and see how it behaves with a “virtual” CPX directly in MakeCode. Do you see that CPX on the left sidebar? That CPX is a simulator that shows how your code will run when eventually loaded on the CPX hardware itself!

Video. Rapidly creating a full program with MakeCode called “Blinky.” We will turn on all the NeoPixels (by setting them red) then pause then turn them off (by setting them black) and repeat “forever.” Code link.

Learning Resources

To learn more, Adafruit and MakeCode have published a series of thoughtful, easy-to-understand tutorials:

Example projects

Next Lesson

In the next lesson, we will make our first MakeCode+CPX program—called Blinky. As we build, we will learn about the MakeCode programming environment, the simulator, and how to load our program on to the CPX.

Next: Programming the CPX with MakeCode

Educational reflections

As someone who has worked with and taught physical computing for nearly a decade, MakeCode addresses several barriers to entry for novices (in rough order of importance):

  • First, the block-based, drag-and-drop interface is far more accessible to novice programmers than Arduino’s IDE and C/C++ environment. And MakeCode generates real JavaScript code based on your block program so you can go back and forth between the two.
  • Second, event handling. A key challenge with Arduino for novices is handling events (e.g., when a button is pressed, do this), especially when programs contain lots of loops (which can make the system seem unresponsive, see this discussion)
  • Third, there is a built-in simulation environment that immediately lets you see how your code will perform before uploading it to your physical CPX device
  • Finally, it is a web-based editor. There is nothing to install and you can program the CPX from your web browser. And once you’ve loaded the editor, it stays cached in your browser (so works offline).

This website was developed by Professor Jon E. Froehlich and the Makeability Lab using Just the Docs. If you found the website useful or use it in your teaching, we'd love to hear from you: jonf@cs.uw.edu. This website and all code is open source (website GitHub, Arduino GitHub, p5js GitHub). You can find the MakeabilityLab_Arduino_Library here. Found an error? File a GitHub Issue.