Do you have an old lamp laying around? Maybe your favorite lamp could use an upgrade! In this guide, you will learn how to take your Circuit Playground Express and use Circuit Python to make an interactive, colorful lamp. We've chosen two Ikea lamps, SPOKA and SJOPENNA, for this project. However, this concept will work with any lamp that you can fit a Circuit Playground Express into and connect it to USB power.
We wanted this project to be as interactive as possible, and that requires some special CircuitPython code. This guide is packed with really cool coding concepts, including a little bit of math. You'll find out different ways to use time. You'll learn how to code different interactions to work together by using generators. You'll discover how to keep repetitive code efficient by using a dictionary. Finally, you'll make an input require multiple steps by creating a state machine.
Let's get started!
First Things First
The first thing you'll want to do is get your Circuit Playground Express and your computer ready to follow along in the guide. If you're completely new to CircuitPython, checkout the Welcome to CircuitPython guide before continuing.
You'll want to make sure your CPX is updated to the most recent version of CircuitPython. Take a look at Installing CircuitPython to get updated if you need to.
CircuitPython code relies on libraries to function. The code in this project will not work without the correct libraries installed! Take a look at CircuitPython Libraries to learn about Installing the CircuitPython Library Bundle.
You'll be writing and editing code through this guide. So, you'll want to choose an editor. You can use any plain-text editor, but code editors make everything much simpler. There are many options. We recommend Mu editor as it is a code editor and serial console all in one! Check out Installing Mu Editor to get that going. You may want to check out Creating and Editing Code if you haven't worked with Mu or CircuitPython code before.
You'll be making significant use of the serial console and REPL. Before getting started, you'll want to make sure you have your serial connection setup. If you're using Mu Editor, you're all set to go already! Check out Connecting to the Serial Console to see how to use the REPL within Mu Editor. If you're using a different editor, you'll want to check out Advanced Serial Console on Windows and Advanced Serial Console on Mac and Linux to get connected. Once connected, take a look at Interacting with the Serial Console and The REPL to get a feel for both.
This guide assumes that you've completed these steps. If you reach a point in the guide where you realise you may have missed one, refer back to this page to get things taken care of and then continue.
Text editor powered by tinymce.