CS 101: Finch Tutorial
Click here to return to the schedule

Getting Started

The Finch is a robot for computer science education. Its design is the result of a four year study at Carnegie Mellon's CREATE lab. Watch the video above to get an idea of how it works. Also take a few minutes to learn about the Finch Hardware.

To connect to a Finch robot from Python, you will need two files:

  1. Finch API:

      finch.py

  2. USB Driver:

      libhidapi64.so (Linux 64-bit)   libhidapi.dylib (macOS)   hidapi64.dll (Windows 64-bit)
      libhidapi32.so (Linux 32-bit)   libhidapipi.so (Raspbian)   hidapi32.dll (Windows 32-bit)

Example Program

1
2
3
4
5
6
7
8
9
10
11
12
13
import finch
import time

# connect to the Finch robot
robot = finch.Finch()

# green light, move forward
robot.led(0, 255, 0)
robot.wheels(0.75, 0.75)
time.sleep(1.5)

# turn off lights and wheels
robot.halt()

The first line imports the finch.py file, and the second line imports the built-in time module. Not surpisingly, you will use "finch" to control the robot and "time" to control timing.

Line 5 creates a Finch object (defined in the finch module) and assigns it the name robot. If you have multiple robots, simply call finch.Finch() additional times to connect to each one. For example:

romeo = finch.Finch()
juliet = finch.Finch()

Lines 8-10 turn on the LED, turn on the wheels, and pause the program (so the robot can do its thing). After time.sleep returns, Line 13 turns off the LED and both wheels. Note the following details:

For this week's lab, you must bring a program of your own design to test out on the Finch. Start with the above example, and add several more led, wheels, and sleep instructions between Lines 10 and 13. Try to get the robot to move around in a creative way. Use different colors to indicate which part of the program is currently running.