Once you've learned the basics of how to blink lights, move servos, and handle inputs, it often comes naturally to want make a larger project that does more than one thing -- more LEDs, more servos, and more buttons and other inputs.

One thing you'll quickly find is that as you add more things to your circuit and code, they are each delaying each other. So one blinking LED works fine, but when you add the second, their blinking patterns are always affecting each other. If you slow one down, the other slows as well.

If you add multiple servos, you might notice that you can't get them to move at the same time. One completes its full sweeping motion, and then the other completes its full sweep. They move sequentially, but never at the same time. 

This guide will teach you a technique that you can use to manage multiple things happening at once in your CircuitPython project.

Another way to do multitasking in CircuitPython is with the asyncio library and the async/await keywords. See https://learn.adafruit.com/cooperative-multitasking-in-circuitpython for more information.

Parts

shot of a Black woman's neon-green manicured hand holding up a Circuit Playground Bluefruit glowing rainbow LEDs.
Circuit Playground Bluefruit is our third board in the Circuit Playground series, another step towards a perfect introduction to electronics and programming. We've...
Angled shot of a Adafruit Feather M4 Express.
It's what you've been waiting for, the Feather M4 Express featuring ATSAMD51. This Feather is fast like a swift, smart like an owl, strong like a ox-bird (it's half ox,...
Angled shot of blue, rectangular, microcontroller.
The Adafruit Feather Bluefruit Sense takes our popular Feather nRF52840 Express and adds a smorgasbord of sensors...
A plastic storage box full of various electrical components.
LEDs and passives and
Micro servo with three pin cable
Tiny little servo can rotate approximately 180 degrees (90 in each direction) and works just like the standard kinds you're used to but smaller. You can use any servo...
Sub-micro Servo with three pin cable
This is just about the cutest, tiniest little micro servo we could find, even smaller than the 9-gram micro servos we love so much.  It can rotate approximately 180 degrees (90 in...
USB cable - USB A to Micro-B - 3 foot long
This here is your standard A to micro-B USB cable, for USB 1.1 or 2.0. Perfect for connecting a PC to your Metro, Feather, Raspberry Pi or other dev-board or...

This guide was first published on Oct 08, 2020. It was last updated on Apr 17, 2024.

This page (Overview) was last updated on Mar 08, 2024.

Text editor powered by tinymce.