... | ... | @@ -19,20 +19,27 @@ The plan is to follow the instructions for Lesson 4 [1]. |
|
|
|
|
|
The NXT light sensor was mounted on the car, which was placed on page 69 of of the LEGO Mindstorms Education NXT Base Set 9797 building instruction, as seen in the figure below.
|
|
|
|
|
|
TODO: Insert figure, test setup ex 1
|
|
|
![test setup ex 1](https://gitlab.au.dk/rene2014/lego/raw/master/pdfs/Images/4-1-1.jpg)
|
|
|
|
|
|
After the calibration the program successfully recognized white and black.
|
|
|
The detection was also tested on the remaining colors, where only the very bright colors returned white, and the rest returned black.
|
|
|
Furthermore we discovered that if the `readValue()` call returns an value exactly equal to the `blackWhiteThreshold`, then both the `black()` and `white()` calls will return false, hence the output is undefined.
|
|
|
The test code for this scenario is shown in the code snippet below.
|
|
|
|
|
|
TODO: Insert code snippet, sanity check test program
|
|
|
```java
|
|
|
if(sensor.black())
|
|
|
color = black;
|
|
|
else if(sensor.white())
|
|
|
color = white;
|
|
|
else
|
|
|
color = undefined;
|
|
|
````
|
|
|
|
|
|
### Exercise 2, Line Follower with Calibration
|
|
|
|
|
|
The LineFollowerCal application was programmed to the car and tested on a black line as shown in the figure below.
|
|
|
|
|
|
TODO: Insert figure, test setup ex 2
|
|
|
![test setup ex 2](https://gitlab.au.dk/rene2014/lego/raw/master/pdfs/Images/4-2-1.jpg)
|
|
|
|
|
|
When placed on the left hand side of the black line the car successfully followed the line, by zigzagging across the edge.
|
|
|
When placed on the right hand side of the black line the car turned once around itself before crossing the line, but without following it however.
|
... | ... | |