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 - Light sensor

Light: There are two light sensors present on the robot. These sensors can detect
the levels of brightness (or darkness). These can be used to detect variations in ambient light in a room.

finch hardware


Light Sensing


The command xfinch.light – returns the left and right light sensor readings;
values range from 0.0 (dark) to 1.0 (bright).


To use the command, you can say, for example,

left_light_sensor, right_light_sensor = xfinch.light()

This creates the variables left_light_sensor and right_light_sensor and assigns the values
that the xfinch.light command read in, into these variables.


To see what the sensors are reading in ambient light, go to the FinchPython folder and
run the testfinchfunctions program.
This will give you an idea of what light levels you need to use in your if statement.

Assignment 13:


Program the Finch to move when the room lights are switched on, and stop when they are off.
You will need to use conditional (if) statements and while loops.

Turn the program in to Shared - Student - Pereira - AI 201x - Class color - Finch assignments - 13 Room as roomyourname.


Write a Reflection on what you have learned.