Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e182ba9

Browse files
Merge pull request #1784 from arduino/sebromero/upy-imu-update
Update broken IMU example
2 parents 36d251d + 190ddc1 commit e182ba9

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

‎content/micropython/01.basics/06.board-examples/board-examples.md‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -574,25 +574,24 @@ while (True):
574574

575575
### Sensors
576576

577-
#### IMU (LSM9DS1)
577+
#### IMU (Rev1: LSM9DS1 / Rev2: BMI270 + BMM150)
578578

579-
Access the `accelerometer`, `magnetometer`, and `gyroscope` data from the LSM9DS1 IMU module.
579+
Access the `accelerometer`, `magnetometer`, and `gyroscope` data from the IMU module.
580580

581581
```python
582582
import time
583-
import lsm9ds1
583+
import imu
584584
from machine import Pin, I2C
585585

586586
bus = I2C(1, scl=Pin(15), sda=Pin(14))
587-
lsm = lsm9ds1.LSM9DS1(bus)
587+
imu = imu.IMU(bus)
588588

589589
while (True):
590-
#for g,a in lsm.iter_accel_gyro(): print(g,a) # using fifo
591-
print('Accelerometer: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*lsm.read_accel()))
592-
print('Magnetometer: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*lsm.read_magnet()))
593-
print('Gyroscope: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*lsm.read_gyro()))
590+
print('Accelerometer: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*imu.accel()))
591+
print('Gyroscope: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*imu.gyro()))
592+
print('Magnetometer: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*imu.magnet()))
594593
print("")
595-
time.sleep_ms(500)
594+
time.sleep_ms(100)
596595
```
597596

598597
### Wireless
@@ -1546,4 +1545,4 @@ If you need to stop the audio streaming, you can call `.stop_streaming()`.
15461545

15471546
```python
15481547
audio.stop_streaming()
1549-
```
1548+
```

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /