Simple test¶
Ensure your device works with this simple test.
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
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
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
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