I’ve recently started experimenting with the PiicoDev Colour Sensor. I’ve noticed that when I sample RGB colour values, the sensor gives readings much larger than 255. I understand 255 to be the maximum RGB colour value, so these readings are confusing me. It also happens in the official tutorial video. Can anyone explain what is happening please?
I am using the provided PiicoDev Python module on a Raspberry Pi 4B.
Hey @David1
255 is the maximum value for an 8-bit number
65535 is the maximum value for a 16-bit number - this is the data returned by the sensor.
If you must work with (255) 8-bit, then values can be easily scaled down by dividing by 8 eg.
newValue = oldValue // 8 # use the // (floor division) operator to get an integer result