You have a great project idea and it involves action when something moves. How do you turn that idea into a project? Some type of Rube Goldberg machine? Nope - today there are inexpensive, tiny chips called accelerometers which detect motion in three directions. These can make the measurements for you, allowing you can focus on implementing your project!
Adafruit makes several breakout boards using accelerometers for various projects. In addition, the Adafruit Circuit Playground Express has an accelerometer on-board (at the very center) which works great!
This guide will demonstrate the use of an accelerometer in Microsoft MakeCode and CircuitPython using simple projects which will allow you to quickly incorporate movement sensing in your project.
Movement in two dimensions can be thought of as changing the point you are at on a piece of flat paper. Let's make it graph paper so we can count where we might be. If we start at the center, (0, 0), we can move anywhere to the right or left, which we will call the x direction. We can also move up and down (we'll call y). And we can move both up/down and left/right (which would mean changes in both the x and y directions). This is our shake and rattle.
If we now consider that we can lift something off the graph paper (above it or putting it below it), we get one more set of directions, we'll call z. Using three sets of coordinates to point to a place (like 0,0,0) is called 3 dimensions or 3D which we hear alot about. This is the roll.
Now if I move from one place to another, say (0,0,0) to (10,10,10), I have created an acceleration. Wait, what about a velocity, or steady movement? Well, to start at 0 and stop at 10, you have to get going and slow to a stop, both which both are not a steady change in motion. This change in motion which we can relate to a change in where we move something, is called acceleration.
A device which can measure acceleration, changes in motion, is called an accelerometer. Back in the Space Race, an accelerometer was HUGE. Even ten years ago, an accelerometer for one or two directions was rather expensive. Due to cell phone developments, now accelerometer chips are inexpensive and tiny - yay!