Learn to program

 
  Finch assignments ::

Learning Goal: Understand how to write a program to control a robot, using loops, conditionals and subroutines where appropriate.

 

 
 

Finch Assignment 13 (optional) - Temperature sensor and Accelerometer

 

finch hardware

 Temperature. The Finch has a single thermistor sensor that detects the ambient temperature.
The sensor can also determine the temperature of an object if the object is placed in contact with
the sensor. The temperature sensor is accurate to within 2 degrees Fahrenheit.

The command temperature returns the temperature in degrees Celsius.

You use this by declaring a variable, for example, my_temp

my_temp = xfinch.temperature

 

Accelerometers. The Finch uses a Freescale MMA7660FC 3-axis MEMS accelerometer to detect acceleration.
The sensor can detect accelerations of +/- 1.5 gees. The primary use of the accelerometer is to detect the
direction of gravity, so as to know how the Finch is oriented (flat on the ground, upright, etc). It is also
possible to detect spikes in acceleration caused by tapping or shaking the Finch.

The command acceleration() returns (x,y,z,tap,shake)

x, y and z are the acceleration readings in units of Gs, and range from -1.5 to 1.5

When the Finch is horizontal, Z is close to 1, x and y close to 0.

When the Finch stands on its tail, y and z are close to 0, x is close to -1.

When the Finch is held with the left wing down, x and z are close to 0, y is close to 1.

tap, shake are Boolean values - true of the corresponding event has happened.

 

You use this by declaring a variable, for example, action

action = xfinch.acceleration()

 

Assignment 13:

Write a program to make the Finch's nose turn red if the temperature is above 31 C ( your body temperature is 37 C).

Its nose should turn blue if the Finch is standing on its tail, green if it is horizontal,

and yellow if it is being shaken.

 

To turn it in, look at the instructions below:

  • Go to Google Drive
  • Open the Class Program folder in 'Shared with me'
  • Open your class folder and assignment folder
  • Click on the "New" button on the top left
  • Upload the program from your computer

 

 

Write a Reflection on what you have learned.