-30%

副廠 Ethernet Shield W5100 網路擴展板 相容 Arduino 支持Uno Mega

NT$457 NT$320 未稅

尚有庫存

貨號: 2007161560(A6-15) 分類: 標籤: , ,
  • 商品說明

商品說明

Ethernet W5100網路擴展模組,分別相容官方Shield I 和Shield II網路擴展板。支持UNO, Mega 等基礎板。

 擴展板可以很容易使Arduino成為簡單的Web伺服器或者通過網路控制讀寫數位和類比介面等網路應用。可直接使用IDE中的Ethernet庫檔便可實現一個簡單Web伺服器,或者一般網路用戶端端。同時該模組支援mini SD卡(TF卡)讀寫,該擴展板採用了可堆疊的設計,可直接插到UNO等開發板上。

操作步驟:

(1)硬體連接

使用的是乙太網擴展板W5100/W5500模組,該擴展板採用了可堆疊的設計,可直接插到開發板上。有的網路擴展板上可能連線有些問題,需要手工連接一些線路,可以檢測以下線路是否聯通,如果沒有聯通可按照下面線路連接:

確保連線沒問題就把擴展版插到控制板上

(2)調試

線路連接好後,打開IDE,找到以下常式,直接編譯上傳到開發板即可。

代碼:

============================================================================

#include <SPI.h>

/*

* Web Server

*

* A simple web server that shows the value of the analog input pins.

*/

#include <Ethernet.h>

 

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

 

byte ip[] = { 192, 168, 1, 15 };

 

EthernetServer server(80);

 

void setup()

 

{

Ethernet.begin(mac, ip);

server.begin();

}

void loop()

{

EthernetClient client = server.available();

if (client) {

// an http request ends with a blank line

boolean current_line_is_blank = true;

while (client.connected()) {

if (client.available()) {

char c = client.read();

// if we’ve gotten to the end of the line (received a newline

// character) and the line is blank, the http request has ended,

// so we can send a reply

if (c == ‘n’ && current_line_is_blank) {

// send a standard http response header

client.println(“HTTP/1.1 200 OK”);

client.println(“Content-Type: text/html”);

client.println(); // output the value of each analog input pin

client.print(“welcome to tinyos electronics”);

client.println(“<br />”);

client.print(“//*************************************”);

client.println(“<br />”);

client.print(“”);

client.println(“<br />”);

client.print(“//*************************************”);

client.println(“<br />”);

for (int i = 0; i < 6; i++) {

client.print(“analog input “);

client.print(i);

client.print(” is “);

client.print(analogRead(i));

client.println(“<br />”);

}

break;

}

if (c == ‘n’) {

// we’re starting a new line

current_line_is_blank = true;

} else if (c != ‘r’) {

// we’ve gotten a character on the current line

current_line_is_blank = false;

}

}

}

client.stop();

}

}

=================================================================================

台灣物聯科技 TaiwanIOT