Interactive Programming: Python & Robots

From Tortoise to Finch
Meet Spot
Spy Pup
Robots at Work
Finch Software
Finch Hardware
Birdbrain Lessons
Turtle Lessons

Related Links


October 20, 2018


Jasmine got her Finch to sing Yankee Doodle Dandy!

Below is code to play the scales. You might want to modify it to create your own compositions!

from finch import *

LOW_C = 523
D = 587
E = 659
F = 698
G = 784
A = 880
B = 988
HI_C = 1047

frequencies = [LOW_C, D, E, F, G, A, B, HI_C]

finch = Finch()
duration = 1

for frequency in frequencies:
    finch.buzzer_with_delay(duration, frequency)

The program above uses a list to keep track of frequencies. See Lesson 13 if you're interested in using a dictionary to match keys with notes.


Kupu and Neel did a nice job of compressing their maze folders.

if, elif, and else

Connor has come up with a couple of cool strategies for interactive steering. Here's one that works for both the turtle and the finch:

from turtle import *
import sys

ezra = Turtle()

print("Press f for forward, b for back, l for left, or r for right")
def go():
  move = input("f, b, l, r, or q to quit: ")
  if move == 'f':
  elif move == 'b':
  elif move == 'l':
  elif move == 'r':
  elif move == 'q':


How could you adapt this code to work with the finch?


Below is a code fragment based on work that Connor did last week. What does it do?

import turtle

speed = 20 #How many pixels to move everytime you click
wn = turtle.Screen()
pr = turtle.Turtle()

def up():
    y = pr.ycor()
    y += speed

wn.onkeypress(up, "w")

What's the advantage of this strategy? Could you use this strategy with the finch?

However, in lesson 14, you'll learn how to use the tkinter module with the finch. Here's a short program that uses tkinter that will give you an idea of what you can do with it:

from tkinter import *

root = Tk()

def key(event):
    print("pressed", repr(event.char))
    if event.char == 'q':

def callback(event):
    print("clicked at", event.x, event.y)

root.bind("<Key>", key)
root.bind("<Button-1>", callback)

Could this key binding be used to steer the finch? Could the turtle screen's onkeypress method be used to steer the finch?

October 13, 2018

Individual Work Period

To start the day, half the class will work on the next Finch lesson, and half will work on Escaping the Maze with the turtle. Then we'll switch, so everybody gets Finch time and Turtle time.

If you and one other person would like to team up during this time, that's fine. I can also do a random assignment of partners for people who want a random partner assigned to them.

Why do so many robots look like animals and humans?

Robots have been made to mimic all kinds of animal life, including humans, insects, birds, reptiles, mammals, fish, and even an octopus. Why do so many engineers use animals as the basis for their robot designs? We'll discuss this question and look at a short video about a robotic wild dog.

October 6, 2018

Virtual and Physical Robots

We'll watch a video about robots and discuss the difference between working with virtual and physical robots.

Pair Programming

I'll use a Python program to pick random pairs for pair programming. During the pair programming session, you'll work through the first finch lesson from Birdbrain.

Virtual and Physical Robots

True or False?

We'll take a break by playing a game to get to know each other. You'll take turns telling us one statement about yourself that's true, and one that's false. The rest of us has to guess which statement is true.

September 29, 2018

Welcome to Interactive Programming: Python & Robots! Here's what we'll do today:

  • Complete this background survey.
  • Get to know each other.
  • Get lessons as needed on using Python to:
    • Create and run a program
    • Import a library
    • Print text to the screen
    • Accept user input and store it to a variable
  • Learn some important features of the finch robot.
  • Learn about pair programming.
  • Use pair programming to program a finch's movement.
  • Write a short reflection and sending it to (I'll explain reflections later today).

In Between Times

Are you a complete Python newbie? Work through the text and links on the Finch Software page and then A Visual Introduction to Python to learn some Python basics.

If you're already familiar with Python, skim the the Finch Software page to familiarize yourself with Thonny and then go to Python Turtle Graphics chapter of How to Think Like a Computer Scientist

I sometimes make videos available on class web pages. To watch the videos, you can ask for headphones or use your own headphones or earbuds if you brought them.

Prepare for your first Finch lesson

Download the Finch Python software. Unzip the file and open the FinchPython120 folder.

After pairs have been assigned, decide with your partner which mac you'll attach to your Finch to begin the first lesson. Hook up the Finch to the USB port on your mac. You should see the LED cycle through colors.

From the FinchPython120 folder, open with Thonny. Run the program to see your Finch dance.

Go to Birdbrain Lesson 1. Run the code shown to get the Finch to go forward a bit and then stop. Switch navigator and driver roles for Exercise 1 and for each exercise after that.

At Home

Here are some things you might want to do at home:

This web page was created to supplement a course offered by The Center for Talent Development. CTD This work is licensed under a Creative Commons Attribution 3.0 Unported License. Creative Commons License Terms of Use. Privacy Policy.