Table of Contents

How to Use the APDS Color Sensor with Quarky

Example Description
Discover how to interface the APDS-9960 RGB color sensor with Quarky using PictoBlox. This step-by-step guide walks you through connecting the sensor pins, reading live RGB light intensity into variables, and rendering matching colors on Quarky's display in Upload Mode.

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

  1. First, open PictoBlox.
  2. Click on the Board tab on the toolbar and select Quarky.Select-Quarky-Board-PictoBlox
  3. Next, click on the Connect button and select the appropriate serial port.
  4. 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.
  5. Switch to Upload mode by toggling this button. You’ll observe some changes in the UI.Switch to Upload Mode

Connection Diagram

Quarky Pulse Rate Monitor Connection

ADPS9960 Connection

Connect the Color Sensor Pins to Quarky as follows:

  1. Connect GND of the Color Sensor to GND on Quarky.
  2. Connect VCC of the Color Sensor to V on Quarky.
  3. Connect SDA of the Color Sensor to A1 on Quarky.
  4. 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

    1. Go to the Quarky palette and drag the ‘when Quarky starts up’ block into the scripting area.
    2. Click on Add Extension.Select Quarky Advance Sensors from the extension list
    3. Add the ‘initialize color sensor‘ block from the Advance Sensors palette.Initial Script Quarky APDS Color Sensor
    4. Underneath the initialize color sensor block, add the ‘forever‘ block from Control Palette.
    5. Go to Variables Palette, and click on ‘Make a Variable’ button.
    6. For the Variable Name, enter ‘red’ with Data type set to ‘Number’.
    7. Repeat Step 5 and 6 to create two more variables ‘green‘ and ‘blue‘.
    8. 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.Setting Green Variable Quarky APDS Color Sensor
    9. Repeat Step 8 for ‘red‘ and ‘blue‘ variable.Setting RGB Variables Quarky APDS Color Sensor
    10. 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.Displaying Text on Quarky
    11. To upload the code, click on the Upload Code button.

Uploading

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!