Skip to content

BirdBrainTechnologies/pxt-hummingbird-duo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hummingbird Micro:bit Library

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.

Usage

This package adds blocks for controlling Hummingbird sensor and output ports

Micro:bit Pins Used

  • P0 -- Connected to Headphone Jack
  • P14 -- Serial Rx to Hummingbird
  • P15 -- Serial Tx to Hummingbird

Start Hummingbird

Starts communication with the Hummingbird by redirecting serial to P14/P15, typically placed in "On Start"

Set LED

Sets an LED on ports 1 to 4 to a brightness value from 0 to 100

Set Tri-LED

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

Set Servo

Sets a servo on ports 1 to 4 to an angle from 0 to 180 degrees

Set Motor

Sets a motor on ports 1 or 2 to a speed from -100 to 100

Set Vibration Motor

Sets a vibration motor on ports 1 or 2 to an intensity from 0 to 100

Get Sensor

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

Examples

Example: Control LED with potentiometer sensor

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))
})

License

MIT

Supported targets

  • for PXT/microbit (The metadata above is needed for package search.)