Approved content

The content below is provided by a partner.

CODOmicrobit/pxt-CODO 0.0.3 GitHub

CODO

Library for Grove micro:bit project board https://www.a4.fr/carte-de-prototypage-microbit-codo.html

Examples with Blocks :

Robot Control by hand

Control the robot with your hand

let dir = 0
basic.forever(function () {
    dir = CODO.grove_gesture_reads()
    if (dir == 1) {
        CODO.robotMove(CODO.RobotDirection.Forward, 50)
        control.waitMicros(1000000)
    } else if (dir == 2) {
        CODO.robotMove(CODO.RobotDirection.Reverse, 50)
        control.waitMicros(1000000)
    } else if (dir == 3) {
        CODO.robotMove(CODO.RobotDirection.RotateLef, 50)
        control.waitMicros(1000000)
    } else if (dir == 4) {
        CODO.robotMove(CODO.RobotDirection.RotateRight, 50)
        control.waitMicros(1000000)
    }
})

Robot move until first obstable

Robot go forward until the first wall

basic.forever(function () {
    if (CODO.collisionSensor(CODO.BP.BPA) == true || CODO.collisionSensor(CODO.BP.BPB) == true) {
        CODO.motorStop()
    } else {
        CODO.robotMove(CODO.RobotDirection.Forward, 50)
    }
})

Send color value to serial line

basic.forever(function () {
    serial.writeNumbers([CODO.color(CODO.Color.Red), CODO.color(CODO.Color.Green), CODO.color(CODO.Color.Blue), CODO.color(CODO.Color.Clear)])
})

Examples with JavaScript :

Robot forward at 75%

CODO.robotMove(CODO.RobotDirection.Forward, 75)

Send red color value to serial line

serial.writeLine(CODO.measureDistanceCentimeter(DigitalPin.P0))

Rotation at 75% speed

CODO.robotMove(CODO.RobotDirection.Forward, 75)
CODO.motorDir(CODO.Motors.Motor1, CODO.MotorDirection.Forward)
CODO.motorDir(CODO.Motors.Motor2, CODO.MotorDirection.Reverse)

API :

Motion :

Control Robot speed [0-100%] and direction [forward,backward,turn left, turn right …].

Change the motor direction.

Change the motor speed.

Stop both motors.

Sensors :

Return distance from ultrasonic range sensor (centimeter).

Return analog potentiometer value [0-1023].

Return color from i2c Grove Color Sensor v1.3 or v2.0. It autodetect the sensor version. Output value : [0;65534].

Detect and recognize the gestures from Grove - Gesture

Return collision sensor state [0-1].

Return line sensor state [0-1].

Return button state [0-1].

Display :

Create a new driver Grove - 4-Digit Display.
(from https://github.com/Seeed-Studio/pxt-grove)

Show a 4 digits number on 4-Digit Display
(from https://github.com/Seeed-Studio/pxt-grove)

Set the brightness level of 4-Digit Display at from 0 to 7
(from https://github.com/Seeed-Studio/pxt-grove)

Clear the 4-Digit Display
(from https://github.com/Seeed-Studio/pxt-grove)

Set Led state [0-1]

Actuator :

Set the servomotor position.

License

MIT

Copyright (c) 2020, A4 Technologie

Supported targets

CODO=github:CODOmicrobit/pxt-CODO#v0.0.3