Simple test

Ensure your device works with this simple test.

examples/mc3479_simpletest.py
import time
import board
import mc3479 as MC3479


i2c = board.I2C()  # uses board.SCL and board.SDA
mc3479 = MC3479.MC3479(i2c)

while True:
    accx, accy, accz = mc3479.acceleration
    print("x:{:.2f}m/s^2, y:{:.2f}m/s^2, z{:.2f}m.s^2".format(accx, accy, accz))
    time.sleep(0.5)

Acceleration Data Range

Example showing how to change the acceleration data range

examples/mc3479_acceleration_range.py
import time
import board
import mc3479 as MC3479


i2c = board.I2C()  # uses board.SCL and board.SDA
mc3479 = MC3479.MC3479(i2c)

while True:
    for acc_rate in MC3479.accel_data_rate_values:
        print(
            "Current Acceleration Data Rate Setting: ",
            mc3479.acceleration_output_data_rate,
        )
        for _ in range(10):
            accx, accy, accz = mc3479.acceleration
            print("x:{:.2f}m/s^2, y:{:.2f}m/s^2, z{:.2f}m.s^2".format(accx, accy, accz))
            time.sleep(0.5)
        mc3479.acceleration_output_data_rate = acc_rate

Acceleration Data Rate

Example showing how to change the acceleration data rate

examples/mc3479_datarate.py
import time
import board
import mc3479 as MC3479


i2c = board.I2C()  # uses board.SCL and board.SDA
mc3479 = MC3479.MC3479(i2c)

while True:
    for acc_rate in MC3479.acceleration_output_data_rate_values:
        print(
            "Current Acceleration Data Rate Setting: ",
            mc3479.acceleration_output_data_rate,
        )
        for _ in range(10):
            accx, accy, accz = mc3479.acceleration
            print("x:{:.2f}m/s^2, y:{:.2f}m/s^2, z{:.2f}m.s^2".format(accx, accy, accz))
            time.sleep(0.5)
        mc3479.acceleration_output_data_rate = acc_rate

Low Pass Filter

Example showing how to change the Low Pass Filter Setting

examples/mc3479_lpf.py
import time
import board
import mc3479 as MC3479


i2c = board.I2C()  # uses board.SCL and board.SDA
mc3479 = MC3479.MC3479(i2c)

while True:
    for lpf in MC3479.lpf_values:
        print("Current Low Pass Filter Setting: ", mc3479.lpf_setting)
        for _ in range(10):
            accx, accy, accz = mc3479.acceleration
            print("x:{:.2f}m/s^2, y:{:.2f}m/s^2, z{:.2f}m.s^2".format(accx, accy, accz))
            time.sleep(0.5)
        mc3479.lpf_setting = lpf