How do I send a wireless UDP signal to an Arduino running a Simulink program?

3 次查看(过去 30 天)
I want to send a number 0-255 to an Arduino Uno to be as a duty cycle for a PWM signal. I have a Simulink program that successfully receives a wired signal and makes a PWM signal, but I have trouble when moving to wireless.
Here are the details: I have an Arduino Uno with a Dragino Yun WiFi shield on it. The shield is all set up and is connected to the same WiFi my computer is on. The Arduino is running a Simulink program that simply receives a duty cycle, and sends out a PWM signal based on it. If no duty cycle is available, it waits uses the previous duty cycle it saw (or 0 if none has been sent yet). The block I use to receive is the Arduino WiFi UDP Receive set to port 50001.
This is where I run into trouble. I am a beginner with Matlab wireless connections. Here's an example of the code I tried for sending a number to the Arduino:
>> u=udp('192.168.1.101', 50001);%IP address of the Dragino Yun shield given by the Arduino IDE
>> fopen(u);
>> fwrite(u,50);
>> fclose(u);
I have tried other variations of the upd function but I do not understand it very well. Is there anyone who knows what the Matlab code should look like?
Thank you!

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Arduino Hardware 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by