Skip to content

MKleinSB/pxt-makerbit-calliope

Repository files navigation

MakerBit for Calliope Mini

Build Status

The MakerBit connects to the BBC micro:bit or Calliope Mini with Callio:bit M to provide easy connections to a wide variety of sensors, actuators and other components. This is a package for Microsoft Makecode.

http://makerbit.com/

MakerBit MakerBit+R
MakerBit MakerBit+R with motor controller

Ultrasonic

Attach an external HC-SR04 ultrasonic distance sensor to steer your robots.

MakerBit getUltrasonicDistance

Measures the distance and returns the result in a range from 1 to 300 centimeters or up to 118 inch. The maximum value is returned to indicate when no object was detected.

makerbit.getUltrasonicDistance(DistanceUnit.CM, MakerBitPin.P5, MakerBitPin.P8)

Ultrasonic Example: Distance Graph

let distance = 0
basic.forever(() => {
    distance = makerbit.getUltrasonicDistance(DistanceUnit.CM, MakerBitPin.P5, MakerBitPin.P8)
    led.plotBarGraph(distance, 0)
})

LCD

Use an I2C LCD 1602 to display numbers and text.

LCD Example

makerbit.connectLcd(39)
makerbit.setLcdBacklight(LcdBacklight.Off)
makerbit.showStringOnLcd("MakerBit", 0)
makerbit.showNumberOnLcd(42, 16)
basic.pause(2000)
makerbit.clearLcd()

MakerBit connectLcd

Connects to the LCD at a given I2C address.

makerbit.connectLcd(39)

MakerBit showStringOnLcd

Displays a string on the LCD at a given position. The text is wrapped automatically at line end.

makerbit.showStringOnLcd("Hello world", 0)

MakerBit showNumberOnLcd

Displays a number on the LCD at a given position. The number is wrapped automatically at line end.

makerbit.showNumberOnLcd(42, 16)

MakerBit clearLcd

Clears the LCD completely.

makerbit.clearLcd()

MakerBit setLcdBacklight

Enables or disables the backlight of the LCD.

makerbit.setLcdBacklight(LcdBacklight.On)

MakerBit position

Turns a LCD position value into a number.

makerbit.position(LcdPosition.P16)

License

MIT

Supported targets

  • for PXT/calliope