... | ... | @@ -74,9 +74,30 @@ |
|
|
> ![3](http://gitlab.au.dk/uploads/group-22/lego/a4841d7341/3.png)
|
|
|
|
|
|
>From this exercise we can conclude that the light sensor is not very useful for navigating based on following specific lines of specific colors, as the way that the light sensor works
|
|
|
>## Exercise 4: Line Follower that stops in a Goal Zone
|
|
|
>
|
|
|
>
|
|
|
>#### Task
|
|
|
>Use the ThreeColorSensor to make a line follower that stops in a green goal zone.
|
|
|
>
|
|
|
Code snippet from ThreeColorSensor class:
|
|
|
public boolean white() {
|
|
|
greenCount = 0;
|
|
|
return (ls.readNormalizedValue()> whiteGreenThreshold);
|
|
|
}
|
|
|
|
|
|
//Returns true if threshold is under white and over black
|
|
|
public boolean green() {
|
|
|
greenCount += greenCount + 1;
|
|
|
if (greenCount > 300)
|
|
|
return (ls.readNormalizedValue()>whiteGreenThreshold && ls.readNormalizedValue()> greenBlackThreshold);
|
|
|
else return false;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
>
|
|
|
>#### Result!
|
|
|
>As can be seen in video (??), the ThreeColorSensor program makes the robot follow the black line oscillating in small turns between the black and the white areas untill it enters the green area. >The movement is not very smooth however,
|
|
|
>
|
|
|
>## Exercise 6: Color Sensor
|
|
|
>
|
|
|
>#### Task
|
... | ... | |