With the inclinometer sketch loaded and running on the Circuit Playground, you can now use it to make angle measurements. The general steps are:
- Sight in the top of the object through the plastic tube.
- Hold the Circuit Playground upright and still, then press either button to take a reading.
- The results will be shown on the NeoPixels #0-#8.
- If the #9 NeoPixel is red, try again. The Circuit Playground was either not upright or there was too much motion.
In order for the angle measurement to be accurate, gravity should be sensed only in the X and Y directions. This is done by holding the Circuit Playground upright as shown in the figure below. Don't let it tilt too much to the left or right.
If there were some kind of text display on the Circuit Playground, we could use that to display the angle directly. However, there isn't one, so we need to do something else. The approach taken here is to use the first 8 NeoPixels, #0-#7, to indicate the magnitude of the angle. The sign (+ or -) is indicated on the #8 NeoPixel.
The worksheet includes the following diagram to help determine the angle from the sequence of lit NeoPixels.
To figure out the angle, simply add up each number shown for each NeoPixel that is lit. If the NeoPixel is not lit, do not add in that number.
For example, if these NeoPixels were lit (remember numbering starts with #0):
#1, #3, and #5
We would add up the corresponding numbers:
2 + 8 + 32 = 42
To come up with the value 42. If the #8 NeoPixel had been lit blue, then the value would have been -42.