Spike Prime

Firmware Update: We highly recommend updating to the latest firmware version. This will ensure that your sensor continues to work with Spike.

The 2023 Spike release requires an update to your sensor.

Please download the latest version and follow the upgrade process.

Out of the box setup: your IR Seeker is ready to use, plug it in and it will appear as if it is a colour sensor (unless it is an older V2 firmware). Rather than colour, the board will report the direction of the ball using the same pattern as a clock from the green value of the sensor.

The small switches on the board are used to turn on functionality. The Board Feature Switches page has more details on these settings. These settings can help you to get more features from the board.


Standard Mode: The IR Seeker will make use of the distance sensor block, a basic program to show the current direction of the ball is shown below.

Advanced Mode: The IR Seeker will appear as a colour sensor. A basic program to show the current direction and signal strength is shown below.

The signal strength block uses the 'more sensors' additional block, this can be added by clicking the icon in the bottom left hand corner:

Then select the 'More Sensors' option:

From here you will see some more blocks:


The IR Seeker will appear as if it is a Distance Sensor, we use the method get_distance_cm() to return the direction of the ball.

hub = PrimeHub()

ir_seeker = DistanceSensor('A')

while True:
    #write the direction to the screen every second.

Advanced Python

The main issue with using the IR Seeker as a distance sensor is that it can only provide the ball direction. Often the signal strength is important as well, however we need to use the advanced functionality to use both the ball direction and ball distance (signal strength).

First step is to ensure the switch is set to advanced mode:

DIP Switch 1 - On - DIP Switch 2 - On

import hub

ir_seeker = hub.port.C.device #CHANGE TO YOUR PORT NUMBER
ir_seeker.mode(5, bytes([0,0,0,0]))

while True:
    data = ir_seeker.get()
    direction = data[0]
    print("Direction", direction)
    strength = data[2]
    print("Strength", strength)

For Spike Prime 3.3.1 (and above)

import hub
import color_sensor

import runloop

async def main():
    while True:
        data = color_sensor.rgbi(hub.port.C)
        direction = data[1]
        print("Direction", direction)
        strength = data[2]
        print("Strength", strength)

        await runloop.sleep_ms(1000)


The code will connect to the sensor and then issue a mode change command, the sensor can then be read and the raw values returned and used.


Last updated