This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
您好!
我正在使用 tcs3200颜色传感器,我正在读取2个散射值(最高和最低)。
我想像 Arduino map()函数一样在0-255之间转换此2值,但值不在0-255之间。
示例
MAP (SensorValue、30、70、0、255)
这是我使用的代码。
int 映射(int x、int in_min、int in_max、in out_min、in out_max) { return (x - in_min)*(out_max - out_min + 1)/(in_max - in_min + 1)+ out_min; }