Now, let’s learn about some of the wonderful sensors that come with the Circuit Playground Express.

First, the Circuit Playground can see you! Okay, not really. That would be creepy. But, it can sense light and dark, as well as colors and even your pulse!

The Light Sensor in the upper left of the board (look for the eye icon) is a phototransistor.

Light Sensor

To use it as a light sensor, we can access the light value using cpx.light.

In this exercise, we are going try this feature out. And also, we need somewhere to display the results. This is where the serial console comes in!

The serial console receives output from the CircuitPython board and displays it so you can see it. The Mu Editor has a serial console built into it so we will use it in a bit.



Inside the while loop, print the value of cpx.light.


Click the Download button to download the code.py file.

Drag and drop the downloaded file into the CIRCUITPY volume on your computer.


Open the Mu Editor on your computer.

Click the Load button to get the code from CIRCUITPY.

Click the Serial button.

What is the current light value in the room?

Try holding the Circuit Playground Express under a light. What is the light value now?

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?