Download presentation
Presentation is loading. Please wait.
Published byBruce Melton Modified over 9 years ago
1
Finch Robot Arrays Pepper
2
Light Sensor getLightSensors() It will return an array of 2 integers with: – Left sensor in 0 – Right sensor in 1 Possible array; LeftRightMeaning 8040Right eye is getting less light 2080Left eye is getting less light 40 Both get the same light
3
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 01 8040
4
Obstacle Sensor getObstacleSensors() It will return an array of 2 booleans with: – Left sensor in 0 – Right sensor in 1 Possible array; LeftRightMeaning FalsetrueLeft side only sees obstacle TrueFalseRight side only sees obstacle False No obstacles True Both sides see an obstacle
5
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 01 8040
6
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]
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.