convert 0-255 into decimal between 0-1
What I am trying to do is convert the color values $0-255$ into a decimal form between $0-1$ for example $127.5 = 0.50$ or $191.25 = 0.75$. I know this is simple math but the problem is that with the program I am writing a $0$ represents `ON` and a $1$ represents `OFF` so with a color code of $255$ it should actually be equal to $0.0$ and with a color code value of $0$ it should equal $1.0$. Can someone please tell me how to solve this math has never been a strong point of mine.