Convert Grove sensor degrees to Hue


HI folks,

This might be more of a math question than Particle.

I’d like to take the degree of angle from a Grove rotary angle sensor (0-300) and convert that to a value between 0-65535 which represents the color hue range of a Philips Hue bulb. My math is little rusty. :blush:

Can anyone recommend how to achieve this?



map() would be the function that springs to mind

However, the math for that is reeeealy simple and straight forward :wink:

 x * 65535.0 / 300.0


@ScruffR thank you! I realized just after posting that map() would be suitable. Nonetheless, thanks for the quick reply!