查看完整版本: Arduino Leonardo connect W5100 not work
頁: [1]

Bill.Ren 發表於 2020-3-26 12:04 PM

Arduino Leonardo connect W5100 not work

各位大大好:

我想請教Arduino Leonardo與 W5100利用Socket連接卻無法正常互傳

Arduino Code如下:

#define W5100
#include "SocketIOClient.h"
#include "Ethernet.h"
#include "SPI.h"

SocketIOClient client;

byte mac[] = { 0xAA, 0x00, 0xBE, 0xEF, 0xFE, 0xEE };
char hostname[] = "192.168.0.164";
int port = 5438;

extern String RID;
extern String Rname;
extern String Rcontent;

unsigned long previousMillis = 0;
long interval = 10000;
void setup() {
pinMode(10, OUTPUT);    //for some ethernet shield on the mega : disables the SD and enables the W5100
digitalWrite(10, HIGH);
Serial.begin(9600);
Ethernet.begin(mac);

if (!client.connect(hostname, port))
Serial.println(F("Not connected."));
if (client.connected())
{
client.send("connection", "message", "Connected !!!!");
}
else
{
Serial.println("Connection Error");
while(1);
}
delay(1000);
}

void loop()
{
pinMode(10, OUTPUT);    //for some ethernet shield on the mega : disables the SD and enables the W5100
digitalWrite(10, HIGH);
unsigned long currentMillis = millis();
if(currentMillis - previousMillis >...<div class='locked'><em>瀏覽完整內容,請先 <a href='member.php?mod=register'>註冊</a> 或 <a href='javascript:;' onclick="lsSubmit()">登入會員</a></em></div><div></div>
頁: [1]