The touch sensor and sensor messaging
In this lecture you will learn the basics of sensor communication. You will see how each sensor information is converted into a text message and how you can chat with individual sensors. The focus of this lecture is to teach you the use of the touch sensor.
Connecting the sensor is simple
The simplest thing in the world. You can find four ports on the bottom of your Mindstorms Brick, called 1, 2, 3 and 4. To them you can connect any kind of sensor. The picture below (Figure 1) shows where to find the ports to plug in the sensor. After connecting it with an EV3 cable, you should turn on the EV3 Brick, which automatically detects all input or output devices.
Figure 1 - Plugging the EV3 Touch sensor to the Brick
- Lego Mindstorms EV3 Brick
- EV3 Touch sensor
- EV3 cable
- Ozeki 10 installed
- Lego connection installed in Ozeki 10
- Bluetooth connection on your machine
Video tutorial: 'How to use the Lego Touch sensor in Ozeki 10'
Start Ozeki 10 and open Control Panel!
Before continue reading please make sure that the Brick is already paired to your computer via Bluetooth. On page http://www.ozeki.hu/index.php?owpn=6065 you can find the right guide. After checking the EV3 cable connections with your fingers, you can start the Ozeki 10 webbrowser client by combining the IP address of the Ozeki 10 server with port number 9505. Please log in and start the most useful Ozeki 10 application ever made, called 'Control Panel' (Figure 2). It manages all connections and message flow between them. It will be the only required application in this guide.
Figure 2 - Opening the Control Panel through the GUI
Select the Touch sensor from the connection list!
To detect the sensor, please check how to create a new Lego Mindstorms connection page at http://www.ozeki.hu/index.php?owpn=6067. Keep in mind that the EV3 Brick connection should be manually added. If it is done, select the 'Touch_Sensor_1' connection from the list (Figure 3). The chat box will open. If you cannot find the connection, please try to change the Bluetooth COM port of 'My_lego_1'. There is a useful method on the bottom of the Bluetooth pairing guide to see it how.
Figure 3 - Select Touch sensor to command it through chat
Send the command 'read' when you are pressing the button!
After opening the Touch sensor, you can chat with the device. If you send 'help', you will get all commands which you can use to control your Touch Sensor through Ozeki 10. Please subscribe to the sensor by sending a 'subscribe' command. Then send a 'read' message while keeping the button pressed with your finger. You will see a 'Touch: on' response message in the chat box (Figure 4).
Figure 4 - Receive message 'Touch: on' if pressed
Send 'read' again when the button is released!
It is good that you have subscribed to it, so you can receive sensor messages. By sending 'read' you can test the sensor again. But now release your fingers from the Touch sensor, it will directly respond with a 'Touch: off' message. This is what Figure 5 demonstrates below. You can route these messages to higher level Ozeki 10 applications.
Figure 5 - Receive message 'Touch: off' if released
Open the Events label and check Touch sensor events, including low-level communication!
Over the chat box, you can see an 'Events' label. If you click it, the message history will open. It sorts sensor messages in chronological order, so you can easily find them. You can see when was it sent, who sent it and what was the message. Look for your username and find this message content: 'read'. In the next line you can see that the sensor response was routed towards the user and the message content was 'Touch: on' (Figure 6). This means the sensor was pressed while reading it.
Figure 6 - Look around the sensor events for the read command and response
The EV3 Touch sensor controller commands
These tables contain some commands, which you can send through Ozeki 10. Write a command in the chat box and click on the 'Send' button, then the sensor will respond to your command. Please pay attention to spelling, because the sensor can only accept correct commands.
|read||get a response to read with a 'Touch: on/off' state|
Commands Table - Reads touch state of your Lego Mindstorms EV3 sensor
|help||request the command set|
|subscribe||subscribe to device messages|
|unsubscribe||unsubscribe from device messages|
|subscribers||shows the list of subscribers|
Basic commands Table - General commands for all devices
- Capturing infrared signals using the IR sensor
- How to measure light intensity and how to capture color information
- Using motors and rotary encoders
- Distance measurement, the ultrasonic sensor
- Orientation in space, the gyroscope sensor
- Using the LCD display
- Using indicator leds on the Lego Brick
- Power management and working with the brick battery
- Playing sounds on the Lego speaker