please anyone help me I need convert this code to matlab 🥺
1 回表示 (過去 30 日間)
古いコメントを表示
Pongsatorn
2023 年 11 月 3 日
回答済み: MathWorks MATLAB Hardware Team
2023 年 11 月 6 日
#define SSID "jetusedtoiw" #define PASSWORD "12345678" #define LINE_TOKEN "qrQFE2XheIbfKk4IVSnpD9aL6noBZQGaj0diw4H0ufJ" String message = "ฝนตกแล้วน้า ระวังเป็นหวัดนะ!"; void setup() { Serial.begin(9600); Serial.println(LINE.getVersion());
WiFi.begin(SSID, PASSWORD);
Serial.printf("WiFi connecting to %s\n", SSID);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(400);
}
Serial.printf("\nWiFi connected\nIP : ");
Serial.println(WiFi.localIP());
LINE.setToken(LINE_TOKEN);
}
void loop() { val = analogRead(analogPin); Serial.print("val = "); Serial.println(val); if (val < 500 and x == 0) { LINE.notify(message); delay(1000); } if (val < 500) { x = 1; } else { x = 0; } delay(1000);
0 件のコメント
採用された回答
Edgar Guevara
2023 年 11 月 3 日
Have you tried Bing copilot?
It can give you a general outline to structure your code, like this:
% Assuming 'SSID' and 'PASSWORD' are defined
wifi = wifiConnect(SSID, PASSWORD);
disp(['WiFi connecting to ', SSID]);
while ~wifi.isConnected()
fprintf('.');
pause(0.4);
end
disp(' ');
disp('WiFi connected');
disp(['IP : ', wifi.localIP()]);
% Assuming 'LINE_TOKEN' is defined
LINE.setToken(LINE_TOKEN);
Of course, copilot would give you the following warning:
Please note that this is a simplified version and might not work as expected because MATLAB does not have built-in support for WiFi communication. You would need to use a MATLAB support package for Arduino or another hardware support package for WiFi communication. Also, the wifiConnect, isConnected, localIP, and setToken functions are placeholders for the actual functions you would use to connect to WiFi, check the connection status, get the local IP, and set the token for LINE respectively. You would need to replace these with the actual functions provided by your WiFi and LINE libraries.
I hope this helps! If you have any other questions, feel free to ask.
3 件のコメント
その他の回答 (1 件)
MathWorks MATLAB Hardware Team
2023 年 11 月 6 日
Hi,
Thanks for reaching out to us. You can use MATLAB Support Package for Arduino Hardware to try this workflow.
Here are the steps,
- Install Arduino Support Package, refer to this link to know more https://in.mathworks.com/help/supportpkg/arduinoio/ug/intro.html
- Configure Arduino over WiFi by following steps mentioned in this link, https://in.mathworks.com/help/supportpkg/arduinoio/ug/configure-setup-for-arduino-hardware.html#bvn8wpb-1
- Use readVoltage API to read analog input voltage from an analog pin, https://in.mathworks.com/help/supportpkg/arduinoio/ref/readvoltage.html
- Follow custom library workflow for TridentTD_Linenotify, https://in.mathworks.com/help/supportpkg/arduinoio/custom-arduino-libraries.html
Please feel free to contact our Technical Support Team if you run into any issues,
https://www.mathworks.com/support/contact_us.html
Thanks,
MATLAB Hardware Team
MathWorks
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Troubleshooting in MATLAB Support Package for Arduino Hardware についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!