Python is a popular programming language, written on 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 Finch with Python:

  1. Run in Browser: The easiest option is to program the Finch 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 Finch 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 Finch with a wider range of Python libraries. This Python library is brought to you by the efforts of Jay Jin, Justas Sadzevicius, and others.

Run in Browser

You will be programming your Finch in a browser-based web application. Brython (browser Python) for Finch 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 Finch to your computer. Then go to brython-legacy.birdbraintechnologies.com.

Click Find Robots. Your Finch 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 Finch, 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 Finch, 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 Finch 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.

Documentation

Documentation for the Python API is available at Python API Documentation.

After you have downloaded the Finch Python package, follow the instructions for compiling and running programs.

Important Files and Folders

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

finch.py – The Finch API source file.

finchconnection.py – Used by finch.py for sending/receiving data over USB

hidapi32/64.dll (Windows), libhidapi.dylib (Mac), libhidapi32/64.so (Linux) – Contains the HIDAPI library.

Various example programs written:

  • musicexample.py – Plays from a list of three songs
  • racedriver.py – Drives around in a square
  • lapswimmer.py – Moves the robot forwards until an obstacle is detected, then backwards
  • alarm.py – Beeps until Finch is placed on its tail
  • testfinchfunctions.py – Tests all Finch sensors and outputs

Finch Python API Description.pdf – A local copy of the Finch API documentation

Version Information

Version 1.10 of the Finch Python package is now available and has been successfully tested on Windows XP 32-bit, Windows 7/8 64-bit, Mac OS 10.6, and Ubuntu 12.04 with Python 3.3.1 and Python 2.7.5.

Known Issues and Troubleshooting

Macs made with M1 or M2 chips do not work with the Finch’s Python library; we recommend you use the Run in Browser option instead.

We only support 64-bit Python for Mac.

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.

Issue: You run a correctly compiled program and it hangs after “Connecting to Finch”.  The LED stays in color fading mode.

Possible Causes:

  • The Finch is already connected to another program. For example, if the Finch is connected to the Birdbrain Robot Server, Python will not be able to connect to it.
  • 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
  • The computer went to sleep when the Finch was plugged in and did not properly register Finch upon wakeup. Unplugging the Finch and plugging it back in will solve the issue.
Back to Top