I am trying to adjust the brightness of some led's depending on the acceleration of a childrens swing.I hooked up an mpu6050 sensor to a nodemcu.
So far I managed to get a smooth output resembling a sine wave from the swing as such below.
( More info here sine wave smoothing - childrens swing - Project Guidance - Arduino Forum )
However since my setup needs different mounting on different swings, the values of the swing are different. I'm trying to find a functional solution without any numerical constants.
the amplitude and the maximum height of the wave, the crest value is different depending on the swing.
the resting position, the baseline value of the wave is also different depending on the tilt of the mount of the setup on the swing.
So I'm guessing without any numerical constants I need to calculate the movement of this wave and map it into the brightness of the leds.
I think ideally I would need to get the average of the resting position, 2 consequtive max values (crest values) and 2 consequtive min values (the bottom trough values) and use them to map to brightness however I have not seen any sources to help me with getting sinewave max's.
