# Trig and Physics and micro:bits

This year I am teaching pre-calculus for the first time, and I am committed to doing projects with my students as much as possible. Last semester we created a parabolic trough solar oven and made holiday cookies for students. This semester I decided to start with a unit on trigonometry, and I happened upon an interesting project via Twitter that showed someone sighting a distant object and using a micro:bit’s accelerometer to calculate tilt and thus how tall the object was. What a cool application of computing and trig. I decided to try and create the project for my class.

I decided to spend some time actually creating the thing. I started by attaching the micro:bit to a cardstock tube. The tube could be used to sight the top of a tree or building. We would try to keep the micro:bit on the same side and simply adjust the tilt until an object was sighted through the tube.

I played with different programming languages and decided to use Python, because it had a robust library of math functions. I started with a simple program to just fetch the accelerometer readings when you push a button.

I found that if the tube is held level, the “x” reading was close to 0, the “y” reading was close to a maximum of 1024, and the “z” was close to 0. If I held the tube pointing straight up (90 degrees), “x” was -1024 and “y” was close to 0. “z” remained close to 0. So as you tilt the micro:bit, the “x” accelerometer goes from 0 to -1024 while the “y” accelerometer mirrors it and goes from 1024 to 0.

I did a little searching to figure out how to convert accelerometer readings into an angle of inclination. There are a lot of different formulas out there – probably all correct. One source I found had a very simple equation:

So basically the angle of inclination is the inverse sine of the ratio of the “x” accelerometer to 1g. I had a hard time visualizing why the ratio x/1g would be equivalent to an opposite / hypotenuse, but it started to make sense when I realized the forces at work are really similar to the kinds of forces on an object that slides down an inclined plane.

In the diagram, the parallel force is analogous to the reading on the “x” accelerometer. The perpendicular force or “normal” force is analogous to the reading on the “y” accelerometer. Fgrav is basically 1024, the reading you get when there is a full 1g on an accelerometer.

This triangle is similar to the triangle made by the inclined plane. I made a little sketch that maybe shows this more clearly?

So basically the formula above, the simple inverse-sine operation, works because your angle of inclination is congruent to the angle opposite the “x” acceleration vector. You can find that angle by finding inverse-sine of “x” to “force of gravity”, 1024.

I wrote another Python program that did this math and reported out the angle, and it seems to be reasonably accurate.

Once you know the angle, if you know how far away you are from your object, its height can be found this way.

tan(theta) = height / distance

distance * tan(theta) = height

Easy peasy! This assumes you’re sighting from the ground. We may find we have to adjust for eye height. We can do that. Time to create the student-facing activity.

I put together this packet for the students. My class is super tiny so the kids can go through it as one group. For a larger class I would make groups and do lots of catch and release.

Here’s how it went.

______________________________

We watched the video on the biltmore stick. Students gave me hypotheses around why it worked, and we talked about potential sources of error.

I told the students that with modern technology, we should be able to make a decent height-finding tool. I introduced the micro:bits to them and told them about some of the features. They’re the first kids in my school to use the micro:bits, and they were ENCHANTED by them. You turn them on and they show messages and images, they play a game, and then they tell you to get coding. How fun! The students had a zillion questions about what else the micro:bits can do and how they worked. After the excitement faded just a little, we talked about accelerometers and how they worked, and the students started working through the packet.

I hoped they would be able to struggle through most of it up until they had to write their procedure in Python, but of course that isn’t how it went. We ran up against several big conceptual roadblocks.

- The idea of the x, y, and z-axis accelerometers BLEW THEIR MINDS. It was really tough to visualize which axis was which, and the students twisted and turned the micro:bits every which way. They had a very tough time being systematic about turning the micro:bit on just one axis to narrow down which accelerometers were changing. I hoped they would be able to sort out which axis was which on their own. They could not, and they got frustrated really quickly. I broke down. I just told them which axis was which and what the max and min values were. I have to admit this has been a struggle for me as well. Visualizing the three accelerometers is a challenge and I probably would have felt the same way in this activity.
- The accelerometers are really sensitive. One moment you set the micro:bit level and get a reading of 0. Another moment the micro:bit seems to be in the same position but your reading is -92. Another moment it’s 16. The text scrolls slowly so you don’t really appreciate what those readings look like in the moment. It was hard, then, to ferret out what the max and min values were. They floated around.
- I really thought with their geometry background the students would visualize the similar triangles really quickly. They did not. Looking back, I remember feeling frustrated and like my mind was a little blown when I learned about forces on an inclined plane. So I should have been ready for this. But the whole idea that a force of 1g directed toward the ground could be broken up into the x and y components on the accelerometers, and that they didn’t add up but rather made legs of a right triangle… WHOA. There was yelling. There was almost crying. Emotions were high. Eventually they did seem to understand but I am going to have to do some good formative assessment next class to see what they actually got.

I have a TINY class, only 5 students, and so the yelling and the emotion was totally manageable, but I am SO glad I did not go through this with a bigger class. I would have done a lot more pre-work on gravity, inclined plane forces, and similar triangles.

Today, after all of our drama, the students wrote programs to calculate the angle of inclination and strapped the micro:bits to paper tubes. Next class, we’ll go outside and take measurements. One of my students found an alternate method of measuring the angle that was something similar to this.

It seems to use a distance-formula calculation instead of the force of gravity and it’s interesting how it uses all three axes. I’ll let her try it and see if her results are similar.

I’ll take some pictures of the results of the experiment and hope I get to do this again with a future group! I feel like with better pedagogy this would be a really great activity!

### 2 responses to “Trig and Physics and micro:bits”

### Trackbacks / Pingbacks

- January 25, 2019 -

What a fantastic learning activity Dawn!

Another option is to take a measurement to the height of the object then advance a known distance and take a second reading obtaining a second angle. Students can then calculate the height of the object without having to know the distance from the object.

If your object of measure is a building you may be able to obtain the actual height for comparison. You may be able to estimate the height using scaling and have a second method to compare. Or just try estimation based on the number of floors to the building.

Love reading about your innovative lessons!

Michael