We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 27a28af + 5df1734 commit 9bc2e8bCopy full SHA for 9bc2e8b
examples/bno055_compass_mode.py
@@ -0,0 +1,19 @@
1
+# SPDX-FileCopyrightText: 2024 Tim Cocks for Adafruit Industries
2
+# SPDX-License-Identifier: MIT
3
+import math
4
+import time
5
+import board
6
+
7
+import adafruit_bno055
8
9
+i2c = board.I2C()
10
11
+sensor = adafruit_bno055.BNO055_I2C(i2c)
12
13
+# Set the sensor to compass mode
14
+sensor.mode = adafruit_bno055.COMPASS_MODE
15
16
+while True:
17
+ values = sensor.magnetic
18
+ print("Heading: " + str(180 + math.atan2(values[1], values[0]) * 180 / math.pi))
19
+ time.sleep(1)
0 commit comments