UDP Receive Example
This example shows how to Receive UDP data with the Arduino. The host desktop computer will be used to transmit UDP data.
The UdpReceive_arduino model uses the UDP Receive block to receive an array of uint8's from the host computer.
Use the following steps to deploy the model onto the Arduino:
- Open the model ArduinoUdpReceiveExample.slx
- If you are using an Arduino other than the Arduino Mega 2560, change the configuration parameters to match the board that you are using.
- Double-click on the UDP Receive block and change the ip address and port number to match your network's configuration.
- Place the model in external mode by clicking the run button
As soon as the deployment is finished, the Arduino should be ready to receive UDP data. It will then display the received data after transmission from the host script.
The host script uses the udp functionality from the Instrument Control Toolbox to transmit UDP data.
Use the following steps to transmit data on the host computer:
- Open the transmitting host function UdpTransmit_host.m
- Change the ip address and port number to match your network's configuration. i.e. h = udp('192.168.1.3',8888,'LocalPort',8887,'TimeOut',0.1);
- Run this function to transmit UDP data to the Arduino