Variables

Assignments that teach Variables

Methods in the Finch API that start with set, get, and is can all help illustrate basic variable types, while arithmetic can be used even before control structures are introduced to tie sensor input to motor or light output.

get Methods 

get methods access the sensor values, and return ints or doubles, depending on the method. For example, the method getLeftLightSensor returns an integer corresponding to the intensity of light at the left light sensor, while the method getXAcceleration returns a double corresponding to the number of gees currently being measured along the Finch's x-axis (nose to tail).  

is Methods

is Methods return boolean true/false values based on the Finch's sensors.  In many cases, these methods simply use get methods and test them in a boolean statement.  For example, the code of the API method isTemperature(double limit) is just: return (limit > getTemperature());.  In other cases, the is methods accurately represent the native hardware functionality of the Finch.  For example, the obstacle sensors either perceive an obstacle or don't; like a bumper or switch, they are fully digital.  Dwelling on this distinction with students may help them understand the difference between analog and digital.

set Methods

set methods like setWheelVelocities, setLED, and the inconsistently named buzz take ints as their arguments. In some cases arguments must be constrained to 8-bit ranges. For example, setLED requires that the red, green, and blue values must be between 0 and 255, and setWheelVelocities requires a range from -255 to 255.  The Finch's firmware runs on an 8-bit controller, and thus many of the sensor and output values are defined by an 8-bit range. Emphasizing these Finch-defined ranges can kick off a broader discussion of the ranges of integers and doubles in 32 and 64-bit operating systems.  

Arithmetic

Simple arithmetic can create compelling programs that tie together inputs and outputs even before control structures and looping are introduced. For example, students can create programs that play different tones or set the beak LED based on the orientation of the Finch. Without a loop these programs are not dynamic (they must be re-run to display a newly generated output). Pedagogically this can be quite positive, as students are motivated to learn additional concepts to improve their program.

RSS Feeds

In addition to the methods described above, the RSS readers included in the Java and Python packages can aid in creating compelling programs. Many of the RSS feeds are as easy to instantiate as the Finch object, and have similarly simple to understand get methods for returning such data as the temperature outside or recent earthquake activity.