Basic Operations

Import KOI 2 Library

from future import *
from koi2 import KOI2

KOI Serial Initialization

koi = KOI2(tx, rx)

Initializes the serial connection to KOI.

Parameters:

tx: TX Pin, use P2 for Robotbit EDU

rx: RX Pin, use P12 for Robotbit EDU

KOI Switch Mode

koi.setModel(mode)

Selects the AI mode for KOI.

Parameters:

mode:

mode(decimal number)
Function

0

None Mode

1

Built-in Road Sign Tracking

2

Built-in Item Tracking

3

Custom Tracking Model

4

Built-in Number Tracking

5

Image Classifier

6

Built-in Alphabets Tracking

7

Face Mask Detection

9

Face Attributes Detection

10

Color Blob Detection

32

Line Trace Detection

256

Code Scanner

KOI Camera Orientation

Sets the orientation for the camera.

Parameters:

dir: 0 for Front Facing, 2 for Back Facing

KOI Data Update

Reads data from the KOI.

KOI Buttons

Returns 0 for unpressed, 1 for pressed.

Parameters:

btn: A string value, 'A' for button A, 'B' for button B.

KOI Record Voice Clip

Records a voice clip and save file onto SD Card.

Parameters:

name: File name as a string, must end in '.wav'

duration: Length in seconds, typically 3 seconds

KOI Play Voice Clip

Plays a voice clip from SD Card.

Parameters:

name: File name as a string, must end in '.wav'

KOI Save Picture

Saves a picture.

Parameters:

location: Location of file as a string, '/sd/' for saving on SD Card, '/flash/' for saving onto KOI onboard memory

name: File name as a string, must end in '.jpg'

KOI Show Picture

Displays a picture.

Parameters:

location: Location of file as a string, '/sd/' for saving on SD Card, '/flash/' for saving onto KOI onboard memory

name: File name as a string, must end in '.jpg'

duration: Duration in micro seconds.

KOI Show String

Shows a string.

Parameters:

x: X coordinates of the text

y: Y coordinates of the text

duration: Duration in micro seconds.

color: Color of the text in RGB

text: The text to be shown

Sample Program

Last updated