Approved content

The content below is provided by a partner.

emwta/pxt-iBit 5.0.1 GitHub

iBIT block package for i-BIT robot kit

powered by micro:bit

i-BIT

The package adds support for the i-BIT conroller board from Innovative Experiment INEX.

micro:bit Pin Assignment

The following micro:bit pins are used for analog and digital sensors, DC motor drivers and servo motors:

Motor control Block

Use iBIT’s motor block to drives motor forward and backward. The speed motor is adjustable between 0 to 100.

iBIT.Motor(ibitMotor.Forward, 100)

iBIT.Motor(ibitMotor.Backward, 100)

Spin Block

Spin block is used to control both motors separately. For example, choose one motor spin with forward direction another one spin with backward direction.

iBIT.Spin(ibitSpin.Left, 100)

iBIT.Spin(ibitSpin.Right, 100)

Turn Block

The Turn block is used to to control the robot movment by turning. The one motor will stop, another one is moving. The vipot point is a center of the robot body.

iBIT.Turn(ibitTurn.Left, 100)

iBIT.Turn(ibitTurn.Right, 100)

Motor Stop Block

The Motor Stop block is used to stop both motors. The speed is set to 0 automatic.

iBIT.MotorStop()

Servo Block

Use this block for control the servo’s moving degree from 0 to 180

iBIT.Servo(ibitServo.SV1, 90)

ReadAD Block

This block is used to read the analog input data from the I2C-based ADC integrated circuit, ADS7828. The resolution of conversion is 12-bit. Data will be 0 to 4095. iBIT have 8-ch analog inputs. The pinout voltage range is 0 to +3.3V

Example

basic.showNumber(iBIT.ReadADC(ibitReadADC.ADC0))
let speed = 0
basic.forever(() => {
    for (let speed = 0; speed <= 100; speed++) {
        iBIT.Motor(ibitMotor.Forward, speed)
        basic.pause(50)
    }
    for (let speed = 0; speed <= 100; speed++) {
        iBIT.Motor(ibitMotor.Backward, speed)
        basic.pause(50)
    }
})
input.onButtonPressed(Button.A, () => {
    iBIT.Turn(ibitTurn.Left, 50)
})
input.onButtonPressed(Button.B, () => {
    iBIT.Turn(ibitTurn.Right, 50)
})
input.onButtonPressed(Button.A, () => {
    iBIT.Spin(ibitSpin.Left, 50)
})
input.onButtonPressed(Button.B, () => {
    iBIT.Spin(ibitSpin.Right, 50)
})
basic.forever(() => {
    for (let Degree = 0; Degree <= 180; Degree++) {
        iBIT.Servo(ibitServo.SV1, Degree)
        iBIT.Servo(ibitServo.SV2, Degree)
        basic.pause(10)
        while (Degree == 180) {
            Degree = 0
        }
    }
})
input.onButtonPressed(Button.A, () => {
    iBIT.Servo(ibitServo.SV1, 90)
})
input.onButtonPressed(Button.B, () => {
    iBIT.ServoStop(ibitServo.SV1)
})

License

MIT

Supported targets

iBIT=github:emwta/pxt-iBit#v5.0.1