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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Arduino Hardware에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!