Contents
Make things
Displaying the color got from color sensor on HTML.
It shows mostly the same color as you get, but calibration is needed.
Materials
- obniz Board x1
- power supply for obniz x1
- S11059-02DT(color sensor) x1
How to make
Hardware connection
Connect color sensor to an obniz like the table and the image below.
obniz | S11059-02DT(color sensor) |
---|---|
0 | Vcc |
1 | SDA |
2 | SCL |
3 | GND |

Software
Use toString() function to convert to hexadecimal, and to color code with slice() function.
var redStr = red.toString(16); var greenStr = green.toString(16);
var blueStr = blue.toString(16);
var colorCode = "#" + ("00" + redStr).slice(-2) + ("00" + greenStr).slice(-2) + ("00" + blueStr).slice(-2);