# Spike Prime

{% hint style="info" %}
**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](/updates/latest-version.md) and follow the [upgrade process](/updates/firmware.md).

{% endhint %}

{% hint style="info" %}
**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.
{% endhint %}

The small switches on the board are used to turn on functionality. The [Board Feature Switches](/board-overview/board-feature-switches.md) page has more details on these settings. These settings can help you to get more features from the board.

## Blocks

**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.

![](/files/GGvIeYddS0sezLlem3Pv)

**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.

![](/files/cRpqVx7UdLmFnuflg12V)

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

![](/files/4ekFCcRkdOLymEgtMa2Z)

Then select the 'More Sensors' option:

![](/files/ypgbyLOt97kGbIjwD3cf)

From here you will see some more blocks:

![](/files/9iZQcTzjVtlQdRInhLw3)

## Python

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.

```python

hub = PrimeHub()

ir_seeker = DistanceSensor('A')

while True:
    #write the direction to the screen every second.
    print(ir_seeker.get_distance_cm())
    wait_for_seconds(1)


```

## 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

```python
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)
    
    wait_for_seconds(1)
```

For Spike Prime 3.3.1 (and above)

```python
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)


runloop.run(main())
```

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.

## Introduction

{% embed url="<https://youtu.be/1Tpn-N91d8k>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://irseeker.buildingblockrobotics.com/guides/spike-prime.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
