Approved content

The content below is provided by a partner.

rerokit/pxt-reromicro 0.1.2 GitHub

rero:micro Extension for Microsoft MakeCode

This MakeCode package/extension/library provides driver for rero:micro educational robot.
Read this document at makecode.microbit.org or github.com.

rero:micro

Let’s make some noise!

// Play melody once at program start-up
music.beginMelody(music.builtInMelody(Melodies.PowerUp), MelodyOptions.Once)

Let’s move it, move it~

// rero:micro move forward at speed 50, for 1 second
reromicro.MoveForward(50)
basic.pause(1000)

// rero:micro turn left at speed 30, for 500 miliseconds
reromicro.TurnLeft(30)
basic.pause(500)

// rero:micro brakes
reromicro.Brake()

Sensing obstacle

// Forever loop
basic.forever(function () {

    // Brake rero:micro when obstacle is detected at 15cm away or nearer.
    // Otherwise, keep moving forward at speed 50.
    if (reromicro.ReadUltrasonic() < 15) {
        reromicro.Brake()

    } else {
        reromicro.MoveForward(50)
    }
})

Line tracking

||read line sensors|| function must be called to read all three line sensors first before using ||(x) sensor detects line|| and/or ||(x) line sensor IR intensity|| to get the result.

// Forever loop
basic.forever(function () {

    // read all three line sensors first
    reromicro.ReadLineSensors()

    // Move forward if only center sensor detects line.
    // Turn right if only right sensor detects line.
    // Turn left if only left sensor detects line.
    // Note: This simple program ignores all other possible conditions.
    if (reromicro.LineSensorDetectsLine(LineSensors.Center)) {
        reromicro.MoveForward(50)

    } else if (reromicro.LineSensorDetectsLine(LineSensors.Right)) {
        reromicro.TurnRight(40)

    } else if (reromicro.LineSensorDetectsLine(LineSensors.Left)) {
        reromicro.TurnLeft(40)
    }
})

Colour Splash!

See Microsoft/pxt-neopixel for NeoPixels support.

// Create a NeoPixel strip at pin P1 with 7 LEDs and either standard RGB format.
let strip: neopixel.Strip = null
strip = neopixel.create(DigitalPin.P1, 7, NeoPixelMode.RGB)

// Reduce the brightness to 50.
strip.setBrightness(50)

// Show red colour for 1 sec.
strip.showColor(neopixel.colors(NeoPixelColors.Red))
basic.pause(1000)

// Show blue colour for 1 sec.
strip.showColor(neopixel.colors(NeoPixelColors.Blue))
basic.pause(1000)

// Show rainbow colours.
strip.showRainbow(1, 310)

License

MIT

Supported targets

reromicro=github:ReRoKit/pxt-reromicro
reromicro=github:rerokit/pxt-reromicro#v0.1.2