Skip to content
Parallax Learn

Parallax Learn

  • Welcome
  • Tutorials
        • Tutorial Series head tag

          Tutorial Series
        • Tutorial Series

          The special, classroom-ready series pages are organized collections of tutorials for our most popular hardware and/or languages. The tutorials for each topic are conveniently accessible from a single page, shown in the order it is recommended that they be completed.
        • Robotics Series Head tag

          Robotics Series
        • Robotics Series

          • Artificial Intelligence
          • Cybersecurity: Radio Data tutorialCybersecurity
          • cyber:bot + Python
          • cyber:bot + MakeCode
          • Boe-Bot Tutorial SeriesBoe-Bot
          • Arduino Shield-Bot
          • ActivityBot with C TutorialsActivityBot + C
          • ActivityBot with BlocklyProp Tutorial SeriesActivityBot + BlocklyProp
          • Scribbler 3 Tutorial SeriesScribbler 3
        • Electronics & Programming Series Head tag

          Electronics & Programming Series
          • BS2 Board of Education Tutorial SeriesBS2 Board of Education
          • Propeller C-Language BasicsPropeller C Basics
          • FLiP Try-It Kit C Tutorial SeriesFLiP Try-It Kit + C
          • FLiP Try-It Kit BlocklyProp TutorialsFLiP Try-It Kit + BlocklyProp
          • Badge WX Tutorial SeriesBadge WX
          • Propeller BlocklyProp Basics and ProjectsPropeller BlocklyProp Basics
          • View All Tutorial Series »
        • Browse Tutorials
        • Browse Tutorials

          Individual tutorials sorted by robot or kit, and language.
        • By Robot or Kit
          • ActivityBot
          • SumoBot WX
          • Boe-Bot
          • Shield-Bot
          • cyber:bot
          • Badge WX
          • ELEV-8
          • ARLO
        • By Language
        • By Language

          • Propeller C
          • Arduino
          • BlocklyProp
          • PBASIC
          • Python
          • MakeCode
          • View All Tutorials »
  • Educators
  • Reference
  • Downloads
  • Home
  • All Courses
  • Cybersecurity: Radio Tilt Control

Cybersecurity: Radio Tilt Control

How Measuring Rotation Angles Works

In addition to the microbit module, this project has to import the math module, which contains common trigonometry methods. Then, pause (1000) gives the terminal a second to set up communication with the micro:bit before it has to display any messages.

In the main loop, the x and y axis accelerometer measurements are stored in variables named x and y.

The next block performs a calculation called arctangent. If you have never heard of it, the next page explains it.

The block atan2(x, y) is what returns the angle result, but that result is in radians—a different kind of angle measurement where a half circle is approximately 3.14, or Pi (π), radians instead of 180°. To convert radians to degrees in blocks, use the (…) x 57.296, this is the approximate number that is multiplied by radians to get the degrees.*

Another way to think about the block above is to break it into steps, each in an individual block. For example:

Now that the angle is calculated, the project displays labels for each variable, followed by its value.

*Alternately, the project could multiply by 180 and divide by pi. At this point, there’s a floating point result, and the round block will round to the nearest integer. For example, if the result was 179.5 or higher, it would round to 180. If the value was instead between 179 and 179.499…., it would round to 179 instead.


Printer-friendly version
Measuring Rotation Angles
Prev
Did You Know? Trigonometry and Rotation Angles
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

About | Terms of Use | Feedback: learn@parallax.com | Copyright©Parallax Inc. 2024

© 2025 Parallax Learn • Built with GeneratePress