another servo scaling post i know, but this one has baffled me.
i am playing with a wii nunchuk controller and reading the i2c data.
now so far all works great and i can see the values in the debug screen and i can use the joystick x and y axis to control the two servos through their full range no problem.
the issue is that i would like to also change the control from the stick to the x and y accelorometer axis and control the servos by tilting the controller in either direction.
this works fine however due to the sensor not giving data in the same linear fashion as the sticks do, i.e 0-255 it is making scaling the values somewhat of a challenge.
the x axis accelorometer data goes from min 68 to max 183 and the y axis min 78 to max 183.
now with the joystick i have no issues scaling 0-255 to 75-225 but with the two accelorometer axis it has got me a bit more stumped
tony
i am playing with a wii nunchuk controller and reading the i2c data.
now so far all works great and i can see the values in the debug screen and i can use the joystick x and y axis to control the two servos through their full range no problem.
the issue is that i would like to also change the control from the stick to the x and y accelorometer axis and control the servos by tilting the controller in either direction.
this works fine however due to the sensor not giving data in the same linear fashion as the sticks do, i.e 0-255 it is making scaling the values somewhat of a challenge.
the x axis accelorometer data goes from min 68 to max 183 and the y axis min 78 to max 183.
now with the joystick i have no issues scaling 0-255 to 75-225 but with the two accelorometer axis it has got me a bit more stumped
tony
Last edited: