Approved content

The content below is provided by a partner.

KittenBot/pxt-powerbrick 0.3.9 GitHub

powerbrick

Feature

  1. The module adopts a high-quality plastic shell structure, and its size conforms to Lego standards: 3x7 and 7x7. Combining with Lego, you can make different projects quickly and easily and have more fun with programming.

  2. The anti-reverse PH2.0 cable is adopted to effectively avoid sensor damage caused by incorrect connection, make it safer to use and reduce the probability of damage and consumption of classroom equipment.

  3. A variety of sensors are included, 8 servos and 4 motors can be plugged in the expansion board, which allows children to use their imaginations freely.

  4. Most sensors have multiple functions. For example, the ultrasonic module not only has the function of distance measurement, but also has the function of sound intensity detection, so you can now use the most functions with the least wiring.

  5. The power supply in the Powerbrick kit adopts 18650 lithium battery, which has a large capacity and can be recharged repeatedly, and the battery box has the functions of anti-reverse connection and over-current protection of the lithium battery, so children can use it safely.

Basic usage


    input.onButtonPressed(Button.A, function () {
        basic.showNumber(powerbrick.Ultrasonic(powerbrick.Ports.PORT1))
    })
    input.onButtonPressed(Button.B, function () {
        basic.showNumber(powerbrick.SoundSensor(powerbrick.PortsA.PORT1))
    })



    basic.forever(function () {
        if (powerbrick.Tracer(powerbrick.Ports.PORT1, powerbrick.Slots.A) || powerbrick.Tracer(powerbrick.Ports.PORT1, powerbrick.Slots.B)) {
            music.playTone(262, music.beat(BeatFraction.Whole))
        }
    })


    basic.forever(function () {
        if (powerbrick.Bumper(powerbrick.Ports.PORT1, powerbrick.Slots.A) || powerbrick.Bumper(powerbrick.Ports.PORT1, powerbrick.Slots.B)) {
            music.playTone(262, music.beat(BeatFraction.Whole))
        }
    })


    input.onButtonPressed(Button.A, function () {
        basic.showNumber(powerbrick.DHT11(powerbrick.Ports.PORT1, powerbrick.DHT11Type.TemperatureC))
    })


    basic.forever(function () {
        powerbrick.MotorRun(powerbrick.Motors.M1, -255)
        powerbrick.Servo(powerbrick.Servos.S1, -45)
        basic.pause(2000)
        powerbrick.MotorRun(powerbrick.Motors.M1, 255)
        powerbrick.Servo(powerbrick.Servos.S1, 225)
        basic.pause(2000)
    })


    input.onButtonPressed(Button.A, function () {
        basic.showNumber(powerbrick.GC_Color())
    })
    powerbrick.GC_MODE(powerbrick.GCMode.ColorSensor)


    let now_ges = 0
    powerbrick.GC_MODE(powerbrick.GCMode.Gesture)
    basic.forever(function () {
        now_ges = powerbrick.GC_Color()
        if (!(now_ges == 0)) {
            basic.showNumber(now_ges)
        }
    })


    powerbrick.RfidPresent(function () {
        basic.showString(powerbrick.RfidUUID())
        basic.pause(500)
        powerbrick.RfidWrite(powerbrick.RfidSector.S1, powerbrick.RfidBlock.B0, "hello")
        basic.showString(powerbrick.RfidRead(powerbrick.RfidSector.S1, powerbrick.RfidBlock.B0))
    })
    basic.forever(function () {
        powerbrick.RfidProbe()
    })


input.onButtonPressed(Button.A, function () {
    powerbrick.showColor(powerbrick.colors(powerbrick.NeoPixelColors.Red))
    powerbrick.rgbShow()
})
powerbrick.rgbConnect(powerbrick.Ports.PORT1)


input.onButtonPressed(Button.A, function () {
    powerbrick.MP3Play(powerbrick.PrevNext.Play)
})
powerbrick.MP3Connect(powerbrick.SerialPorts.PORT1)

License

MIT

Supported targets