03 Mission Instructions

Your mission is to develop a robot that mimics how an animal responds to light in its environment.

For additional Biomimcry resources, check out the GoBox course summary page. 

4. Code: Find Your Threshold

Before you can code, you need to connect to your GoPiGo. You can complete this Mission without Advanced Bloxter. 

In order to create a robot that responds to light in the environment, we need to learn a little bit about how the light sensor itself perceives the environment. 

First, we need to find out what the light level is where you are now. Using the drop down menu on the right side of the page, select the port your sensor is attached to (I2C-1 or I2C-2), and choose "Light Color Sensor (Light Mode)". 



Below the dropdown will be the current light sensor reading. Try covering the sensor on your robot with your hand and you’ll see that this is a live-stream of the sensor data. 



Now write down the numbers you see when the robot is in each of these states.

State 1: When your robot is out in the open, with the lights on, what number does the sensor report?
State 2: When your robot is in its cave or fort, with the lights still on, what number does the sensor report?
State 3: When your robot is out in the open, but the lights are off, what is the sensor reading?
State 4: And when your robot is in its cave or fort, but the lights are also off, what is the sensor reading?



When we write our animal behavior program, we are going to use an if-then statement to tell the GoPiGo what to do after it checks the value from the light sensor. We can’t just ask if it is light or dark though — we have 100 different amounts of light and dark that the sensor might see. We need to pick a threshold value — a value somewhere between the normal range of light and dark in the space where you are working —for our program to compare to. You may have to use trial and error to find the best threshold value for your space, but to start, choose a number between the sensor readings for States 1 & 2