> For the complete documentation index, see [llms.txt](https://docs.andymark.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.andymark.com/frc-electronics/koors40-brushed-speed-controller/can-+-pwm-am-5600_can/examples.md).

# Examples

## Wiring Note

The Koors40 CAN brushed speed controller comes with one set of twisted pair wires that are yellow and green. For CAN bus control, wiring is as expected and matches the colors of the CAN bus. For PWM control, the green wire acts as ground and the yellow wire acts as the PWM signal

### Code Example

You must first install the AndyMark vendor libraries. Instructions can be found [here](/frc-electronics/wpilib-am-vendor-library-setup.md)

View [Device API](/frc-electronics/koors40-brushed-speed-controller/can-+-pwm-am-5600_can/device-api.md) for a comprehensive list of commands

{% tabs %}
{% tab title="Java" %}

```java
import com.andymark.jni.AM_CAN_Koors40;

//Initialize Device
//The device's default CAN is 0. Change it using AndyMark IPK
//SystemCore Bus 2 with device ID 0
myKoors40 = new AM_CAN_Koors40(2,0);

//commands to set brake and coast mode
myKoors40.setBrakeMode();
myKoors40.setCoastMode();

//Command to set speed (-100 - 100)
myKoors40.setSpeed(mySpeed);
```

{% endtab %}

{% tab title="C++" %}

```
//File to include
#include "AM_CAN_Koors40.h"

//Initialize Device
//The device's default CAN is 0. Change it using AndyMark IPK
//SystemCore Bus 2 with device ID 0
CAN_Koors40 myKoors40{2,0};

//commands to set brake and coast mode
myKoors40.setBrakeMode();
myKoors40.setCoastMode();

//Command to set speed (-100 - 100)
myKoors40.setSpeed(mySpeed);
```

{% endtab %}
{% endtabs %}
