A library for using the Hummingbird Duo with a Micro:bit
To use this package, go to https://makecode.microbit.org/, select "Advanced" and then "Add Package" and copy the package URL - https://github.com/BirdBrainTechnologies/pxt-hummingbird - in the resulting dialog.
This package adds blocks for controlling Hummingbird sensor and output ports
P0
-- Connected to Headphone JackP14
-- Serial Rx to HummingbirdP15
-- Serial Tx to HummingbirdStarts communication with the Hummingbird by redirecting serial to P14/P15, typically placed in "On Start"
Sets an LED on ports 1 to 4 to a brightness value from 0 to 100
Sets a Tri-color LED on ports 1 or 2 to the color specified by red, green, and blue brightness values. The values range from 0 to 100
Sets a servo on ports 1 to 4 to an angle from 0 to 180 degrees
Sets a motor on ports 1 or 2 to a speed from -100 to 100
Sets a vibration motor on ports 1 or 2 to an intensity from 0 to 100
Reads the value of the sensor on ports 1 to 4. Readings range from 0 to 100 and linearly correspond to a voltage from 0 to 5 volts on the sensor port
The Hummingbird has a potentiometer, or rotary knob. This example simply dims the LED on port 1 based on the reading of a sensor on port 1. Any sensor will work, but the potentiometer is easiest to use in this case.
// Starts communication with Hummingbird
hummingbird.startHummingbird()
// Sets LED on port 1 to the value of the sensor (ranges from 0 to 100)
basic.forever(() => {
hummingbird.setLED(FourPort.One, hummingbird.getSensor(FourPort.One))
})
MIT