基础工作:W5100扩展板插在ARDUINO上。用网线把W5100和自己家的路由器连接。插上网线能看到侧面网口指示灯变亮。路由器开启DHCP服务(一般都是开启的)。

1.打开官方例程里面的Ethernet->WebClient

2.修改里面的谷歌服务器为百度的。

3.修改IP地址为本地的局域网号码段,比如你的电脑是192.168.1.100。那么设置你的w5100,也在192.168.1.x。后面的x不能与局域网内的其它设备重复。

4.下载代码,看效果。

 /*
Web client This sketch connects to a website (http://www.google.com)
using an Arduino Wiznet Ethernet shield. Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13 created 18 Dec 2009
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe, based on work by Adrian McEwen */ #include <SPI.h>
#include <Ethernet.h> // Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(74,125,232,128); // numeric IP for Google (no DNS)
char server[] = "www.baidu.com"; // name address for Google (using DNS) // Set the static IP address to use if the DHCP fails to assign
IPAddress ip(,,,); // Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client; void setup() {
// Open serial communications and wait for port to open:
Serial.begin();
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
} // start the Ethernet connection:
if (Ethernet.begin(mac) == ) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
// try to congifure using IP address instead of DHCP:
Ethernet.begin(mac, ip);
}
// give the Ethernet shield a second to initialize:
delay();
Serial.println("connecting..."); // if you get a connection, report back via serial:
if (client.connect(server, )) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /search?q=arduino HTTP/1.1");
client.println("Host: www.baidu.com");
client.println("Connection: close");
client.println();
}
else {
// kf you didn't get a connection to the server:
Serial.println("connection failed");
}
} void loop()
{
// if there are incoming bytes available
// from the server, read them and print them:
if (client.available()) {
char c = client.read();
Serial.print(c);
} // if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop(); // do nothing forevermore:
while(true);
}
}

能显示服务器返回的数据,证明通讯成功。

ARDUINO W5100 WebClient 测试的更多相关文章

  1. ARDUINO W5100 WebServer测试

    1.直接下载官方的enternet->WebServer代码 /* Web Server A simple web server that shows the value of the anal ...

  2. PS2手柄在arduino上进行测试,可用,供喜欢diy的朋友借鉴

    #include <PS2X_lib.h> //PS2手柄PS2X ps2x; // create PS2 Controller Class//////////PS2引脚///////// ...

  3. [Arduino] Arduino Uno R3 中文介绍

    Arduino UNO是Arduino USB接口系列的最新版本,作为Arduino平台的参考标准模板.UNO的处理器核心是ATmega328,同时具有14路数字输入/输出口(其中6路可作为PWM输出 ...

  4. Arduino可穿戴教程之第一个程序——上传运行程序(四)

    Arduino可穿戴教程之第一个程序——上传运行程序(四) 2.4.5  上传程序 现在所有Arduino IDE的设置都完成了,我们就可以将示例程序上传到板子中了.这非常简单,只需要单击如图2.45 ...

  5. Arduino UNO的原理图

    Arduino UNO的原理图是开源的,所以可以从arduino网站上下载它: https://www.arduino.cc/en/Main/ArduinoBoardUno 原理图PDF: https ...

  6. Arduino UNO R3

    Arduino 常见型号 当然还有 LilyPad,附图: 最常见的自然是UNO,最新版是第三版R3: 国内也有一些改进的板子.我用的是一般的板子,拿到货也只能默默了. 简介 The Uno is a ...

  7. SpringCloud升级之路2020.0.x版-40. spock 单元测试封装的 WebClient(下)

    本系列代码地址:https://github.com/JoJoTec/spring-cloud-parent 我们继续上一节,继续使用 spock 测试我们自己封装的 WebClient 测试针对 r ...

  8. Arduino+ESP32 之 驱动GC9A01圆形LCD(一),基于Arduino_GFX库

    最近买了一块圆形屏幕,驱动IC是GC9A01,自己参考淘宝给的stm32的驱动例程, 在ubuntu下使用IDF开发ESP32,也在windows的vscode内安装IDF开发ESP32,虽然都做到了 ...

  9. CoopyIII开发文档之控制LED灯开关

    作者:那年:QQ:843681152 一. CooplyIII环境的搭建 工欲善其事必先利器,如何搭建CooplyIII的开发环境是一切coolpyIII开发的前提.CoolpyIII作者内cool超 ...

随机推荐

  1. JavaScript字符编解码

    示例代码: <!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF ...

  2. 【Java】各种软件安装与环境配置的失败

    又来到了java的世界,看了一段时间的视频.感觉太空虚,便从网上找到一个教程.想做几个demo试试,少不了的前期准备:Java开发环境配置,Eclipse JSP/Servlet 环境搭建等.     ...

  3. int a[3];中a+1与&amp;a+1差别 -- C

    int a[3]; a 和 &a 的地址一样的. a+1 == a + 1*sizeof(int);跳跃是一个数组元素大小 &a+1 == a + 3*sizeof(int);跳跃是整 ...

  4. &&与&符号区别

    http://topic.csdn.net/u/20080915/16/f5125300-f69f-4da8-9c3a-a7458590553f.html && 与 &区别: ...

  5. [分享]windows下编译squid的经验(转)

    squid是什么我这里就不说了,这不是本文的重点,总之它是一个集:代理.加速.缓存.负载均衡.防盗链.访问控制等多功能的一个超牛X开源软件,如今已经广泛应用于很多领域.对于缓存和加速这一领域,如今各大 ...

  6. MySQL四-1:数据类型

    阅读目录 一 介绍 二 数值类型 三 日期类型 四 字符串类型 五 枚举类型与集合类型 一 介绍 存储引擎决定了表的类型,而表内存放的数据也要有不同的类型,每种数据类型都有自己的宽度,但宽度是可选的 ...

  7. centos root登录password 忘记解决的方法

    Centos系统 登陆root忘记password 解决方式: (1)开机启动系统,在进入linux系统之前按键Esc 进入例如以下界面:(须要注意:Centos是安装在虚拟机里面的话,须要将鼠标点进 ...

  8. Unity动态字体在手机上出现字体丢失问题解决

    在我们游戏的开发过程中,在部分手机上运行游戏的时候,出现了字体丢失的问题,出问题的手机似乎用的都是高通芯片. 使用的unity是4.2.0版本,ngui是3.4.9版本. 在unity的论坛及unit ...

  9. Docker-Compose 自动创建的网桥与局域网冲突解决方案

    环境: 使用docker-compose.yml 部署应用,docker 默认的网络模式是bridge ,默认网段是172.17.0.1/16  ,不巧的是我们局域网也使用的172.22. xx 网段 ...

  10. Argparse 命令行解析模块常用参数

    Argparse模块可以轻松编写用户友好的命令行界面.该程序定义了它需要的参数,argparse 并将找出如何解析这些参数sys.argv.该argparse 模块还会自动生成帮助和用法消息,并在用户 ...