7172| 3
|
[常见问题] X-link wifi module v3与安卓手机通讯问题 |
我想用该wifi模块与安卓手机进行通讯,安卓手机上的程序是使用processing写的,手机是server,Arduino是client,下面是我操作的流程:1 我按照产品说明书https://wiki.dfrobot.com.cn/index.php/(SKU:TEL0078)WIFI_Shield_V3_PCB_Antenna_WIFI%E6%89%A9%E5%B1%95%E6%9D%BF_V3_PCB%E5%A4%A9%E7%BA%BF 上的操作将手机的wifi热点和arduino上的wifi模块连起来,连接成功后的样子如下 2下面是我的安卓手机里面的processing程序: import netP5.*; import oscP5.*; import ketai.net.*; OscP5 oscP5; NetAddress remoteLocation; char data; String myIPAddress; String remoteAddress = "192.168.43.167"; void setup() { orientation(PORTRAIT); textAlign(CENTER, CENTER); textSize(36); initNetworkConnection(); background(78, 93, 75); smooth(); } void draw() { fill(255); ellipse(270,250,200,200); text( "Local IP Address: \n" + myIPAddress + "\n\n" + "Remote IP Address: \n" + remoteAddress , width/2, height*0.6); } void mousePressed(){ if(dist(270,250,mouseX,mouseY)<100){ if(mousePressed==true) { OscMessage myMessage = new OscMessage("Data"); myMessage.add('a'); oscP5.send(myMessage, remoteLocation); } } } void initNetworkConnection() { oscP5 = new OscP5(this, 12000); remoteLocation = new NetAddress(remoteAddress, 12000); myIPAddress = KetaiNet.getIP(); } 3下面我就仿照样例程序写了一段arduino程序接收手机传来的信息 int led_r = 11; int val; void setup() { pinMode(led_r, OUTPUT); digitalWrite(led_r, LOW); Serial.begin(115200); } void loop() { if(Serial.available() > 0) { val=Serial.read(); Serial.println(val); if(val=='a'){ digitalWrite(led_r, HIGH); } } } 最后,我发现arduino根本接收不到安卓手机中processing程序发送来的字符,估计是processing程序和arduino程序不兼容,不知各位网友有没有关于这种arduino wifi模块与安卓手机的processing程序联机的代码?? |
© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed