Simple test
Ensure your device works with this simple test.
examples/mc3479_simpletest.py
1# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
2#
3# SPDX-License-Identifier: MIT
4
5import time
6import board
7import mc3479 as MC3479
8
9
10i2c = board.I2C() # uses board.SCL and board.SDA
11mc3479 = MC3479.MC3479(i2c)
12
13while True:
14 accx, accy, accz = mc3479.acceleration
15 print("Acceleration X: ", accx)
16 print("Acceleration Y: ", accy)
17 print("Acceleration Z: ", accz)
18 time.sleep(0.5)
Acceleration Data Range
Example showing how to change the acceleration data range
examples/mc3479_acceleration_range.py
1# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
2#
3# SPDX-License-Identifier: MIT
4
5import board
6import mc3479 as MC3479
7
8
9i2c = board.I2C() # uses board.SCL and board.SDA
10mc3479 = MC3479.MC3479(i2c)
11
12print("Current Acceleration Range")
13print("Acceleration Range", mc3479.acceleration_range)
14print("Changing Acceleration range to 8G")
15mc3479.acceleration_range = MC3479.ACCEL_RANGE_8G
16print("Acceleration Range", mc3479.acceleration_range)
17print("Changing Acceleration Range to 4G")
18mc3479.acceleration_range = MC3479.ACCEL_RANGE_4G
19print("Acceleration Range", mc3479.acceleration_range)
20print("Changing Acceleration Range to 16G")
21mc3479.acceleration_range = MC3479.ACCEL_RANGE_16G
22print("Acceleration Range", mc3479.acceleration_range)
Acceleration Data Rate
Example showing how to change the acceleration data rate
examples/mc3479_datarate.py
1# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
2#
3# SPDX-License-Identifier: MIT
4
5import board
6import mc3479 as MC3479
7
8
9i2c = board.I2C() # uses board.SCL and board.SDA
10mc3479 = MC3479.MC3479(i2c)
11
12print("Current Acceleration data rate", mc3479.acceleration_output_data_rate)
13print("Changing Acceleration data rate to 25 Hz")
14mc3479.acceleration_output_data_rate = MC3479.BANDWIDTH_25
15print("Changed Acceleration data rate", mc3479.acceleration_output_data_rate)
16print("Changing Acceleration data rate to 62.5 Hz")
17mc3479.acceleration_output_data_rate = MC3479.BANDWIDTH_62_5
18print("Changed Acceleration data rate", mc3479.acceleration_output_data_rate)
19print("Changing Acceleration data rate to 1000")
20mc3479.acceleration_output_data_rate = MC3479.BANDWIDTH_1000
21print("Changed Acceleration data rate", mc3479.acceleration_output_data_rate)