问题
I need to detect in which direction the item is moving. I want to know if the item is moving up or down.
Is this possible with this platform and by using a specific shield?
I had in my mind the ultrasonic sensor, with which I would measure how far the item is from a certain point, and with this suggest what type of movement is happening because of the distance changes. I think this might be tricky, and wanted to see if there are better alternatives.
UPDATE: I updated the question, corrected directions - it's not forward/backward but up/down.
回答1:
In general, to know direction of movement you need use gyro measurements results, usually represented as quaternions. To obtain distance you need integrate acceletation data. But notice that this method is not very tolerate. You may use 6 axis mems sensors, which measure acceleration and rotation speed. There are arduino shields based on Invensense's ICs mpu6050 and mpu9250. Try libraries such as i2cdevlib. Also maybe useful to implement native Invensense's firmware, it is ported to ARM and microchip platforms, and should be easy to move the codes to arduino platform. Another useful link is freeImu.
来源:https://stackoverflow.com/questions/36245649/arduino-detecting-motion-movement