Introduction
Color sensors are fascinating electronic components used everywhere from automated sorting lines in factories to advanced smart packaging systems that inspect product quality! Learn what an RGB color sensor is, how optical light wavelength detection works, how to interface the APDS-9960 color sensor with Quarky, and program it with ease in PictoBlox – our Scratch blocks-based graphical programming platform with advanced hardware interaction abilities. Once you’re equipped with the basic knowledge of I2C communication, reading RGB light intensity, and mapping color values, we’ll show you how to detect vibrant surface colors and build exciting DIY smart sorting machines and interactive robotics projects using Quarky.
To work in PictoBlox, you’ll first need to download it from HERE.
Ready? Set. Go!
Prerequisites
- APDS9960 Color Sensor to detect the color.
- Quarky as the main controller.
- PictoBlox to create and run the program.
- Jumper Wires
How to connect with Quarky
- First, open PictoBlox.
- Click on the Board tab on the toolbar and select Quarky.

- Next, click on the Connect button and select the appropriate serial port.
- In the top right corner, there is a toggle button named Mode. This button is used to switch between the two working modes of PictoBlox, namely the stage mode and the upload mode.
- Switch to Upload mode by toggling this button. You’ll observe some changes in the UI.

Connection Diagram

ADPS9960 Connection
Connect the Color Sensor Pins to Quarky as follows:
- Connect GND of the Color Sensor to GND on Quarky.
- Connect VCC of the Color Sensor to V on Quarky.
- Connect SDA of the Color Sensor to A1 on Quarky.
- Connect SCL of the OLED Display to A2 on Quarky.
Note: Refer to the connection diagram for the exact wire placement, pin position, and orientation.
Step-by-Step Block Coding Guide
-
- Go to the Quarky palette and drag the ‘when Quarky starts up’ block into the scripting area.
- Click on Add Extension.

- Add the ‘initialize color sensor‘ block from the Advance Sensors palette.

- Underneath the initialize color sensor block, add the ‘forever‘ block from Control Palette.
- Go to Variables Palette, and click on ‘Make a Variable’ button.
- For the Variable Name, enter ‘red’ with Data type set to ‘Number’.
- Repeat Step 5 and 6 to create two more variables ‘green‘ and ‘blue‘.
- Inside the forever block, add ‘set () to ()‘ block from Variables Palette. Set the variable to ‘green‘ and for its value, add the ‘get () light level‘ block from Advance Sensors palette with ‘green‘ option selected in the dropdown.

- Repeat Step 8 for ‘red‘ and ‘blue‘ variable.

- Next add the ‘display () with ()’ block from Display palette. For the text, enter ‘A‘ and for the color, add ‘set R () G () B ()’ block from Display palette. Use the ‘red‘, ‘green‘ and ‘blue‘ variables from Variables palette for the color values.

- To upload the code, click on the Upload Code button.

Output
Conclusion
In this lesson, we learned how to interface the APDS-9960 RGB color sensor with Quarky. Using PictoBlox’s Upload mode alongside the Advance Sensors extension, we explored how to read and store dynamic red, green, and blue light levels into system variables. By combining these real-time color intensity values with Quarky’s display blocks, we successfully reflected the detected surface colors directly on Quarky’s screen. With an understanding of I2C-based color sensing and data visualization now under your belt, you are fully prepared to apply these principles to create automated color sorters, quality-control systems, and vibrant interactive robotics projects!


