Porting Programs from NxtJLib, Event Model Purpose: Use the EV3 as autonomous rover with a EV3 color sensor. Move the rover on a black floor. Whenever the rover leaves the floor, move it back, so that it remains trapped on the black area forever. This is exactly the same purpose as in the fifth example of the NxtJLib website. Because the class design of EV3Lib and NxtJLib is the same, the modifications for the source code when porting programs from the NXT to EV3 and vice versa are trivial, despite the completely different hardware and firmware of the two bricks. Again the Java event model is used here to emphasize the elegance of handling robot behavior by callback methods. import ch.aplu.ev3.*; Discussion: Here the new EV3 color sensor is used as light (luminosity) sensor. If you attach the former NXT light sensor, you must use the class NxtLightSensor instead of LightSensor. Because the EV3 color sensor reports light intensity values different from the NXT light sensor, you must adapt the trigger level and even use the dark() callback instead of the bright() callback. Better you make some preliminary tests by writing out the reported light values with the following short calibration program: import ch.aplu.ev3.*; Compilation/download using the OnlineEditor of PHBern (Bern University of Teacher Education)
| ||||