I am looking to make a motion sensor that activates a LED light when hit with force. I am making a hurdle for my major work and I need the breadboard to sit vertically and it will sit on the back of the hurdle bar. So when the hurdle bar is hit the motion sensor will activate and a LED will further turn on. I don’t know if you would be able to help in assisting a code that works and a diagram to show where the pieces should go on the board, I’m using a piico dev motion sensor, and have an Arduino UNO board
That seems more complex than the task should require. With a motion sensor like the PiicoDev the code will need to determine orientation on reset, then check for any deviation from this orientation. The connection requires use of communication libraries. It’s excellent for detecting orientation and acceleration of a drone, but overkill for someone hitting a hurdle.
A hardware solution using a shock detector will be much simpler, requiring the code to only detect whether the sensor is open or closed. There is a full example here.
KY-002 Shock Sensor Module - Arduino Project Hub
Note that shock sensors come in a variety of sensitivities, so you could look at several to see which responds best to the shocks you are checking for.
Thank you very much, that is what I’m after
Welcome to the forum!!
Sounds like an awesome project!
At the moment Core doesn’t have any libraries available for the Arduino - they’re definitely in the works though! Check out the Factory for updates!
It might be worth going for a Raspberry Pi Pico along with the PiicoDev expansion board as well as an appropriately sized cable.
Hooking the two up will consist of plugging in the two PiicoDev connections and hooking up an LED in series with a resistor.
As for the code, that’s the fun part! and to avoid any plagiarism down the line it might be best for some references or examples to get posted rather than working code.
Core has some excellent tutorials on using them with the Pico’s: https://core-electronics.com.au/tutorials/piicodev-motion-sensor-mpu-6050-raspberry-pi-pico-guide.html
Let us know if there are any other areas to clarify!
Excellent point Jeff! It looks like Core stock’s some under the name of “Vibration Switch Sensors”
You can manually calculate the absolute G-force by reading from an accelerometer as follows. This way the measurement is independent of the sensor’s orientation.
Here we take the acceleration in the X, Y and Z components and find the magnitude of the combined vector.
gforce = sqrt( accX*accX + accY*accY + accZ*accZ);
You can then check that the instantaneous value is higher/lower than some set threshold.
The PiicoDev Motion Sensor uses an MPU-6050 IMU, for which there are numerous Arduino libraries available through the Arduino Library Manager. We’re working on MicroPython compatibility with PiicoDev at the moment - but the sensor will still work with these libraries. At most you might have to specify the address that the PiicoDev module defaults to.
Depending on the library you choose, it may even have shock-detection functionality built-in