Color Sensor

With QikEasy EV3 Spike Prime Adapter and your existing EV3 Color Sensors, you have additional sensors at your disposal on Spike Prime or Robot Inventor.  You are no longer limited by the number of sensors you have.

Extra Color Sensors always ready for use at your command

Many robotic projects use multiple Color Sensors.  So it is essential to have an extra one handy all the time.

 

These are some examples of projects that use multiple Color Sensors:

 

  • Color Block Sorter that uses one color sensor to detect color of the block, and another to find the bucket of the matching color.
  • A Better Line Follower can use two color sensors  for following a line with more accuracy.
  • A Rubik Cube Solver can certainly benefit from multiple color sensors for reading the colors of the cubes.

 

 

How to use it on Spike Prime or Robot Inventor?

  1. Connect your EV3 Color Sensor to the bigger socket on the QikEasy Adapter.
  2. Connect one end of a Spike Prime cable to the smaller socket on the QikEasy Adapter.
  3. Connect the other end of the Spike Prime cable to one of the 6 ports on the Spike Prime (or Robot Inventor) hub.
  4. Your Spike Prime or Mindstorms Hub will detect your EV3 Color Sensor through the QikEasy Adapter as a Spike Prime Color Sensor.

 

Programming with an EV3 Color Sensor through a QikEasy Adapter

 

Through the use of a QikEasy Adapter, your EV3 Color Sensor emulates a regular Spike Prime Color Sensor.  As such, you can use the EV3 Color Sensor in exactly the same way as a normal Spike Prime or Robot Inventor Color Sensor.

Compare to a regular Spike Prime Color Sensor, the only thing missing in our EV3 emulated Color Sensor is the ability to turn on the LED light on the front face of the sensor.

Accessing Low Level Modes with Python

Word Editor only allows user to access Discrete Colors, RGB Colors and Reflective Index.  With Python, you would be able to access other low level modes.  The following example shows how you can use Python to access the Low Level Color Sensor modes supported by our adapter.  When you try this code, make sure you will change line 5 so that color_sensor points to the correct Port.

 

import hub
from utime import sleep_ms

# See https://lego.github.io/MINDSTORMS-Robot-Inventor-hub-API/class_device.html for documentation
color_sensor = hub.port.A.device

def decode_color( code ):
    if code==None or code<-1 or code>10:
        return "Unknown"
    else:
        return {
            -1: "No Color",
            0: "Black",
            1: "Violet",
            2: "Unknown",
            3: "Blue",
            4: "Teal or Light Blue",
            5: "Green",
            6: "Unknown",
            7: "Yellow",
            8: "Unknown",
            9: "Red",
            10: "White"
        }[ code ]

color_sensor.mode(0)
for x in range(30):
    sleep_ms(500)
    c = color_sensor.get(0)[0];
    print("Mode(0):Discrete Color=", decode_color(c), "(", c, ")")

sleep_ms(1500)

color_sensor.mode(1)
for x in range(30):
    sleep_ms(500)
    print("Mode(1):REFL", color_sensor.get(0))

sleep_ms(1500)

color_sensor.mode(2)
for x in range(30):
    sleep_ms(500)
    print("Mode(2):AMBI", color_sensor.get(0))

sleep_ms(1500)

color_sensor.mode(4)
for x in range(30):
    sleep_ms(500)
    print("Mode(4):RAW REFL", color_sensor.get(0))

sleep_ms(1500)

color_sensor.mode(5)
for x in range(30):
    sleep_ms(500)
    print("Mode(5):RGB", color_sensor.get(0))

sleep_ms(1500)

color_sensor.mode(6)
for x in range(30):
    sleep_ms(500)
    print("Mode(6):HSV", color_sensor.get(0))