Mạch chuẩn giao tiếp Ethernet sang SPI ENC28J60 là IC ethernet của hãng Microchip, module ENC28J60 sử dụng chuẩn giao tiếp SPI với 8KB bộ đệm. Module ENC28J60 là module có giá rẻ nhỏ gọn, khả năng truyền nhận tốt, tích hợp hầu như các protocol, tốc độ truyền dữ liệu lên đến 20MHz.
MODULE | InduinoX / Arduino UNO (ATMEGA328) | Arduino MEGA |
VCC | 3.3V Pin | 3.3V Pin |
GND | GND | GND |
CS | SS - PIN 10 | SS - PIN 53 |
SI | MOSI - PIN 11 | MOSI - PIN 51 |
SCK | SCK - PIN 13 | SCK - PIN 52 |
WOL | PIN 5 | PIN 5 |
SO | MISO - PIN 12 | MISO - PIN 50 |
INT | Interrupt 0 - PIN 2 | Interrupt 0 - PIN 2 |
Sơ đồ đấu cho UnoR3
Sơ đồ đấu cho Mega2560
Download thư viện Arduino tại đây
Open Arduino IDE Files - Examples - ENC28J60 - WebServer
The IP address in the example code need to be changed for the address assigned to ENC28J60 module.
#includebyte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; byte ip[] = { 10, 0, 0, 177 }; Server server(80); void setup() { Ethernet.begin(mac, ip); server.begin(); } void loop() { Client 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 for (int i = 0; i < 6; i++) { client.print("analog input "); client.print(i); client.print(" is "); client.print(analogRead(i)); client.println(""); } 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; } } } // give the web browser time to receive the data delay(1); client.stop(); } }
Giao hàng trong 24h
Với đơn hàng trên 500.000 đBảo đảm chất lượng
Sản phẩm bảo đảm chất lượng.Hỗ trợ tức thời
Hotline: 0833.811.811Sản phẩm 100% chính hãng
Sản phẩm nhập khẩu chính hãngVận chuyển miễn phí cho đơn hàng trên 1.000.000 VNĐ nội thành HCM
Hỗ trợ thanh toán tiền mặt và thẻ visa của tất cả các ngân hàng
Hỗ trợ chăm sóc khách hàng 24/7, Liên hệ giải đáp mọi thắc mắc
TAE Shop là điểm mua hàng được yêu thích và lựa chọn