Skip to content
Project: Colour Picker

Code Upload

Remember the paint store scanner from the introduction? Time to turn your hardware into that scanner. One upload, and your Colour Picker is ready to read the world.

Warning

Before uploading, double-check your 4 wires: Vin, GND, D1 → SDA, and D2 → SCL. A loose I2C connection is the #1 reason uploads succeed but nothing happens. Head back to the Wiring module if you need a refresher.

Upload the Code

Click the button below to open Kriya Station with the Colour Picker code pre-loaded. Follow the instructions in the Station to compile and upload to your NodeMCU.

Open in Kriya Station

What to Expect

Once the upload finishes, open the Serial Monitor in Kriya Station. You won't see anything happen yet — the Colour Picker is a one-shot tool. It waits for your command.

  1. Hold the sensor 1–2 cm from a coloured surface.
  2. Type "S" in the Serial Monitor and hit Enter.
  3. The sensor takes 5 rapid readings, filters out noise (trimmed mean — remember the Olympic judges?), and processes the result.
  4. You get precise RGB and HEX values printed once.

Info

Expected output:R: 142   G: 58   B: 201   |   HEX: #8E3AC9

Tip

For the best results, hold the sensor close to the surface in a well-lit area. The auto-ranging adjusts for brightness, but extreme darkness or direct sunlight can throw off readings.

Try It Out

Here are some experiments to put your Colour Picker through its paces:

01

Scan 3 Objects

Pick three coloured objects — a red pen, a green leaf, a blue notebook. Scan each one and write down the RGB values.

02

Match Digitally

Open any colour picker website and enter the HEX code. Does the colour on screen match the real object? How close is it?

03

Lighting Challenge

Scan the same object in sunlight, then under a desk lamp, then in a dim room. Auto-ranging should keep values close — but you might spot small shifts. That's real-world sensing!