Upload
bruce-melton
View
212
Download
0
Embed Size (px)
Citation preview
Finch Robot Arrays
Pepper
Light Sensor
• getLightSensors()• It will return an array of 2 integers with:– Left sensor in 0 – Right sensor in 1
• Possible array; Left Right Meaning
80 40 Right eye is getting less light
20 80 Left eye is getting less light
40 40 Both get the same light
Access Light Sensor array
• Make a variable of integer array type to hold the response:
int[ ] lights ;• Call the getLightSensors() method to retrieve
the array: lights = myFinch.getLightSensors();
• Access the value:–lights[0]; //gets left value–lights[1]; // gets right value
0 1
80 40
Obstacle Sensor
• getObstacleSensors()• It will return an array of 2 booleans with:– Left sensor in 0 – Right sensor in 1
• Possible array; Left Right Meaning
False true Left side only sees obstacle
True False Right side only sees obstacle
False False No obstacles
True True Both sides see an obstacle
Access Obstacle Sensor array
• Make a variable of boolean array type to hold the response:
boolean[ ] obs;• Call the getObstacleSensors() method to
retrieve the array: obs= myFinch.getObstacleSensors();
• Access the value:–obs[0]; //gets left value–obs[1]; // gets right value
0 1
80 40
Summary• Two commands for retrieving sensor array from
the Finch: – getObstacleSensors()– getLightSensors()– Both put left in 0 index and right in 1 index– Obstacle returns boolean and light returns int– Create an array to hold the response
• Int[ ] or boolean[ ] arrayname– Call the method to fill the array setting your array
variable = the method call– Read the result as arrayname[index]