I'm learning Arduino by working on simple projects. I have an issue with the MPU6050 program with Arduino. I wanted to sweep servo based on the pitch and roll reading from the sensor, however, as the sensor auto-calibrates, if the sensor is not parallel to ground level it calibrates the value it gets as normal reading (i.e) if the sensor is parallel to ground, it should show 0 as reading which is normal value and then changes to negative or positive based on the rotation, if the sensor is inclined to ground level when its calibrating, say 10, it reads that value as normal and then increases or decreases based on the angle the sensor rotates. To sweep the servo from 0 to 180 deg, I need the least negative value and most positive value to be mapped from 0 - 180.
I tried to check the reading to map, sometimes the values will be all negative for example ranging from -10 to -100 sometimes completely positive eg: 10 - 150 sometimes both and negative like -50 to 50. the calibration gives random numbers, is there a way to map them with least number and highest number?
Any leads much appreciated, thank you.
I'm learning Arduino by working on simple projects. I have an issue with the MPU6050 program with Arduino. I wanted to sweep servo based on the pitch and roll reading from the sensor, however, as the sensor auto-calibrates, if the sensor is not parallel to ground level it calibrates the value it gets as normal reading (i.e) if the sensor is parallel to ground, it should show 0 as reading which is normal value and then changes to negative or positive based on the rotation, if the sensor is inclined to ground level when its calibrating, say 10, it reads that value as normal and then increases or decreases based on the angle the sensor rotates. To sweep the servo from 0 to 180 deg, I need the least negative value and most positive value to be mapped from 0 - 180.
I tried to check the reading to map, sometimes the values will be all negative for example ranging from -10 to -100 sometimes completely positive eg: 10 - 150 sometimes both and negative like -50 to 50. the calibration gives random numbers, is there a way to map them with least number and highest number?
Any leads much appreciated, thank you.