|
All sensors from the current Lego EV3 product line are supported. They are modelled by software in a class named by the sensor type, as there are:
All sensor use the same programming concept: An instance of the sensor is created using the constructor that specifies the sensor port. To read a sensor value, typically a read or get method is issued. In many cases sensor values are requested in a repeating loop, we say, that "the sensor is polled periodically". To allow the program to terminate smoothly, the push buttons is clicked. In this function it is called Escape-Button.
Polling the touch sensor In this basic program to poll the EV3 touch sensor at port S1 uses a data acquisition loop with a time interval of 100 ms and displays the state of the sensor at the OLED display. It is terminated by pressing the escape button.
Since output from Python print commands are sent to stdout (standard out), you cannot see them unless you run the program in a console window. However if you are using the TigerJython IDE and you terminate the RaspiBrick firmware monitor by clicking Tools | Terminate Python on Target, the output to stdout is capture by the TigerJython message window. This is very convenient for debugging purposes.
Displaying ultrasonic sensor data in the console window Since output from Python print commands are sent to stdout (standard out), you cannot see them unless you run the program in a console window. However if you are using the TigerJython IDE and you terminate the RaspiBrick firmware monitor by clicking Tools | Terminate Python on Target, the output to stdout is capture by the TigerJython message window. This is very convenient for debugging purposes.
If you stop the RaspiBrick firmware, you can even use an endless loop, since a running program is automatically terminated by TigerJython when a new program is downloaded.
Because robot.exit() is not called, the BrickPi3 system is not resetted and it remains in a undefined state. But the constructor of LegoRobot will reset it at the next program run.
NXT sensors Many sensors from the old Lego NXT product line are supported. They are modelled by software in a class named Nxt followed by the sensor type, as there are:
The programming concept remains the same as for the EV3 sensor.
|
|||||