# Pixy camera

The Pixy2 camera driver communicates via I2c to get all the detected vectors and their indexes.

#### Initialization

```c
void Pixy2Init(I2c_AddressType PixyI2cAddress, uint8 PixyI2cChannel);
```

Parameters:

·       PixyI2cAddress: The I2c address configured on the Pixy2 via the Pixymon app.

·       uint8 PixyI2cChannel: The I2c channel configured for the camera in the Peripherals tool.

#### Setting the RGB LED color

```c
void Pixy2SetLed(uint8 Red, uint8 Green, uint8 Blue);
```

Useful for debugging purposes

Parameters:

·       uint8 Red, Green, Blue: The desired LED color values, between 0 and 255.

#### Getting the detected vectors

```c
void Pixy2GetVectors(DetectedVectors *DetectedVectors);
```

Parameter:

·       DetectedVectors: The address of the variable where to store the vectors. The buffer must be declared by the user.

#### Relevant structures

```c
typedef struct{
    I2c_AddressType I2cAddress;
    uint8 I2cChannel;
}Pixy2;
```

```c
typedef struct {
    uint8 NumberOfVectors;
    Vector Vectors[100];
} DetectedVectors;
```

```c
typedef struct{
    uint16 x0, y0, x1, y1;
    uint8 VectorIndex;
}Vector;
```

Note: The last two structures are not defined in pixy2.h, but in main\_types.h, as they are used by other car drivers too.


---

# 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://nxp.gitbook.io/nxp-cup/2024-fall-2025-nxp-cup-bare-metal-drivers/drivers-description-and-usage/pixy-camera.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.
