Python is a popular programming language, written on top of C. Its syntax allows programmers to write in fewer lines of code, and is easy for new programmers to learn.

You have two options for using the Hummingbird Duo with Python:

  1. Run in Browser: The easiest option is to program the Hummingbird in the browser through brython-legacy.birdbraintechnologies.com, as shown in the Run in Browser instructions. This website is compatible with Chromebooks as well as Mac/Windows/Linux computers. Choose this option if you are using a Chromebook, are unable to download software, or just want to keep things simple.
  2. Download Software: These instructions will show you how to use the Hummingbird with an offline Python IDE on Mac/Windows computers. Choose this option to use an IDE such as IDLE that will enable you to use the Hummingbird with a wider range of Python libraries.

Run in Browser

You will be programming your Hummingbird Duo in a browser-based web application. Brython (browser Python) for Hummingbird Duo requires the Chrome browser. You can install that here.

To use the BirdBrain Brython web app, you must make sure the Chrome settings allow third-party cookies.

Connecting

Use the USB cord to connect the Hummingbird to your computer, and connect the AC power adapter. Then go to brython-legacy.birdbraintechnologies.com.

Click Find Robots. Your Hummingbird robot will appear. Click on the name of the robot and then click Connect

Running and Saving Programs

Brython loads with a sample program. To run the program on your Hummingbird, click the play button. There are also buttons to stop the program and to save/download Brython code to your drive or upload Brython code from your drive.

Offline Use

You can use the Brython app online or offline. To use Brython offline with the Hummingbird, install it on your computer using the orange install button.

Download & Install

1. Download and install Python. Python 2.7+ and Python 3.3+ are supported:

For Mac or Linux, download the most recent, stable version of 64-bit Python.

For Windows, install 32-bit Python from this page (even if you have a 64-bit version of Windows).

2. Download and unzip our Hummingbird Python library.

LINUX USERS ONLY:

You will need to install libusb-1.0. To do so, run sudo apt-get install libusb-1.0-0-dev in any terminal window. You will need to run a script prior to running the Hummingbird for the first time. Make it executable by typing chmod +x Configure and then run sudo ./Configure in the top level directory of the HummingbirdPython package.

Compiling Python Programs

Documentation of the Python Hummingbird API can be found here.

Option 1: Use IDLE to run python Open up IDLE (Python GUI), which should be installed on your computer after installing python and open one of the example files.

Option 2: Use Terminal/Command Line to run python Windows: Navigate to where the python file is stored, and type your program’s name with the extension (.py). Mac: Navigate to where the python file is stored, and type python followed by your program’s name (including .py). Linux: Navigate to where the python file is stored, and type python followed by your program’s name (including .py).

Option 3: Use interactive mode to send commands to the Hummingbird Open Terminal/Command Prompt, navigate to the location of hummingbird.py, and type python.

Something like Python 3.3.0 (v3.3.0:, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit (Intel)] on win32 Type “help”, “copyright”, “credits” or “license” for more information. >>> should pop up. Note: If “‘python’ is not recognized as an internal or external command, operable program or batch file.” appears, then follow the directions here to correct the PATH.

Now type the following commands: from hummingbird import Hummingbird humm = Hummingbird() Now to access any function in the API, simply type humm.functionName()

Important Files and Folders

The following files and folders are common to all Hummingbird Python downloads:

hummingbird.py – The Hummingbird API source file.

hummingbirdconnection.py – Contains low level functions for sending and receiving data over USB, used by hummingbird.py

hidapi32/64.dll (Windows), libhidapi.dylib (Mac), libhidapi32/64.so (Linux) – Compiled C libraries used by hummingbirdconnection.py to scan for USB devices (specifically, the Hummingbird) and open a connection. dll files are for Windows, dylib is for OSX, and so is for Linux.

Various example programs written in python using pyhumm.py:

  • cricketexample.py – Chirps with vibration motor based on the temperature
  • driverexample.py – Spins the motors, speed depending on how far an object is from the distance sensor
  • LEDexample.py – Adjusts the brightness of the LEDs depending on background sound levels
  • hummingbirdTester.py – Tests all of the hummingbird API functions.

OS Support

The Hummingbird Python library has been tested on Windows XP 32-bit Windows 7/8 64-bit Windows 10 64-bit, Mac OS 10.6, and Ubuntu 12.04 with Python 2.6, 2.7, and 3.3. If you choose to use Linux, we recommend using Ubuntu with our robots. The library may also work with other versions of Linux, but we are only able to provide technical support for Ubuntu.

Known Issues and Troubleshooting

Windows:

  • We only support 32-bit Python for Windows, but you can use the library on 64-bit versions of Windows so long as you install a 32-bit version of Python.

Mac:

  • On a Mac, you must search for the libhidapi64.dylib and libhidapi32.dylib libraries and copy them into the Mac’s /usr/local/lib directory. To find this directory, select Go/Go to Folder in the Finder. If the directory does not exist, you can create it in Terminal with the following command: sudo mkdir /usr/local/lib
  • We have not included 32-bit support for Mac.
  • Macs made with the M1 chip do not work with our Python library. We recommend using the Run in Browser option if you have this type of Mac.
Back to Top