First time user so apologies for being uninformed on posting procedures ECT.
My current project is stabilizing a flying wing UAV using a MPU which I use to correct the rudders on each wing. This works fine if I write an actual value for the servo write function: RightServo.write(0)
LeftServo.write(110).
However, if replace the value and instead try this function:
RightServo.write(map(mpu.getAccX(), 0.20, 0.45, 60 ,0))
Serial monitor doesn't show any data and the UAV is unresponsive
So, what am I doing? I'm trying to get the "servo/Rudder" to move proportionally based on the amount of angle I rotate the UAV as I hold it in bench testing.
I have tried defining the value to be mapped as a: int, long, float, etc.
and it doesn't change the result
I don't see how I can share my code, besides copy and paste, which won't look appealing? Suggestions
Thank you.
Thank you for response, the values I get from the IMU are from decimals from 0-1
so, if map only accepts integers than can I simply multiply them by a magnitude of 100 to resolve the issue.
@jremington
Thank you very much for the patience and guidance you solve my problem
SOLUTION : as mentioned earlier I multiplied the decimal values by order of 100
and the
*NEW_VALUE = mpu.getAccX()100 I had to make it a FLOAT type since ( int , long ) did not suffice
Now the rudders maintain parallel to ground while UAV body rotates.
Very grateful have been using these forums for years and most issues have been resolved so i never needed an account till now.