Approved content
The content below is provided by a partner.
Library for Grove micro:bit project board https://www.a4.fr/carte-de-prototypage-microbit-codo.html
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 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)
}
})
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)])
})
CODO.robotMove(CODO.RobotDirection.Forward, 75)
serial.writeLine(CODO.measureDistanceCentimeter(DigitalPin.P0))
CODO.robotMove(CODO.RobotDirection.Forward, 75)
CODO.motorDir(CODO.Motors.Motor1, CODO.MotorDirection.Forward)
CODO.motorDir(CODO.Motors.Motor2, CODO.MotorDirection.Reverse)
Control Robot speed [0-100%] and direction [forward,backward,turn left, turn right …].
Change the motor direction.
Change the motor speed.
Stop both motors.
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].
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]
Set the servomotor position.
MIT
Copyright (c) 2020, A4 Technologie
CODO=github:CODOmicrobit/pxt-CODO#v0.0.3