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

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

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

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

4.下载代码,看效果。

  1. /*
  2. Web client
  3.  
  4. This sketch connects to a website (http://www.google.com)
  5. using an Arduino Wiznet Ethernet shield.
  6.  
  7. Circuit:
  8. * Ethernet shield attached to pins 10, 11, 12, 13
  9.  
  10. created 18 Dec 2009
  11. by David A. Mellis
  12. modified 9 Apr 2012
  13. by Tom Igoe, based on work by Adrian McEwen
  14.  
  15. */
  16.  
  17. #include <SPI.h>
  18. #include <Ethernet.h>
  19.  
  20. // Enter a MAC address for your controller below.
  21. // Newer Ethernet shields have a MAC address printed on a sticker on the shield
  22. byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
  23. // if you don't want to use DNS (and reduce your sketch size)
  24. // use the numeric IP instead of the name for the server:
  25. //IPAddress server(74,125,232,128); // numeric IP for Google (no DNS)
  26. char server[] = "www.baidu.com"; // name address for Google (using DNS)
  27.  
  28. // Set the static IP address to use if the DHCP fails to assign
  29. IPAddress ip(,,,);
  30.  
  31. // Initialize the Ethernet client library
  32. // with the IP address and port of the server
  33. // that you want to connect to (port 80 is default for HTTP):
  34. EthernetClient client;
  35.  
  36. void setup() {
  37. // Open serial communications and wait for port to open:
  38. Serial.begin();
  39. while (!Serial) {
  40. ; // wait for serial port to connect. Needed for Leonardo only
  41. }
  42.  
  43. // start the Ethernet connection:
  44. if (Ethernet.begin(mac) == ) {
  45. Serial.println("Failed to configure Ethernet using DHCP");
  46. // no point in carrying on, so do nothing forevermore:
  47. // try to congifure using IP address instead of DHCP:
  48. Ethernet.begin(mac, ip);
  49. }
  50. // give the Ethernet shield a second to initialize:
  51. delay();
  52. Serial.println("connecting...");
  53.  
  54. // if you get a connection, report back via serial:
  55. if (client.connect(server, )) {
  56. Serial.println("connected");
  57. // Make a HTTP request:
  58. client.println("GET /search?q=arduino HTTP/1.1");
  59. client.println("Host: www.baidu.com");
  60. client.println("Connection: close");
  61. client.println();
  62. }
  63. else {
  64. // kf you didn't get a connection to the server:
  65. Serial.println("connection failed");
  66. }
  67. }
  68.  
  69. void loop()
  70. {
  71. // if there are incoming bytes available
  72. // from the server, read them and print them:
  73. if (client.available()) {
  74. char c = client.read();
  75. Serial.print(c);
  76. }
  77.  
  78. // if the server's disconnected, stop the client:
  79. if (!client.connected()) {
  80. Serial.println();
  81. Serial.println("disconnecting.");
  82. client.stop();
  83.  
  84. // do nothing forevermore:
  85. while(true);
  86. }
  87. }

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

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. Oracle基础 程序包

    一.程序包 程序包是一种数据库对象,它是对相关PLSQL类型.子程序.游标.异常.变量和常量的封装.程序包包含两部分内容: 1.程序包规范:可以声明类型.变量.常量.异常.游标和子程序. 2.程序包主 ...

  2. 杂(三)-The type java.lang.Object cannot be resolved It is indirectly referenced ...

    The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files ...

  3. 利用 apache bench 模拟并发请求

    示意代码如下 ab -n 1000 -c 10 http://127.0.0.1/ -n 指的是总的请求,默认值是 1 -c 指的是并发数,默认值是 1 -t 指的是测试的总时间,测试所进行的最大秒数 ...

  4. Linux系统字符集乱码问题

    假设你在安装Linux的过程中就选择了中文.可能能够省去步骤1.2.反之.假设你先安装了英文环境,而后希望它支持中文,则能够1.2步 1.首先在linux中安装中文包安装中文简体包rpm -ivh k ...

  5. 利用python 掌握机器学习的过程

    转载:http://python.jobbole.com/84326/ 偶然看到的这篇文章,觉得对我挺有引导作用的.特此跟大家分享一下. 为了理解和应用机器学习技术,你需要学习 Python 或者 R ...

  6. React 学习推荐

    推荐学习一.React 入门实例教程     作者: 阮一峰 http://www.ruanyifeng.com/blog/2015/03/react.html 瘳雪峰的Javascript教程 ht ...

  7. [译]GLUT教程 - 移动镜头1

    Lighthouse3d.com >> GLUT Tutorial >> Input >> Move the Camera I 下面来看一个更有趣的GLUT应用.本 ...

  8. C语言include预处理命令与多文件编译

    #include预处理命令几乎使我们在第一次接触C的时候就会碰到的预处理命令,可我现在还不怎么清楚,这次争取一次搞懂. 一.#include预处理指令的基本使用 预处理指令可以将别处的源代码内容插入到 ...

  9. two sum, three sum和four sum问题

    1. two sum问题 给定一组序列:[-4 -6 5 1 2 3 -1 7],然后找出其中和为target的一对数 简单做法:两层循环遍历,时间复杂度为n^2 升级版:对给定的序列建立一个hash ...

  10. HDFS源码分析数据块复制选取复制源节点

    数据块的复制当然需要一个源数据节点,从其上拷贝数据块至目标数据节点.那么数据块复制是如何选取复制源节点的呢?本文我们将针对这一问题进行研究. 在BlockManager中,chooseSourceDa ...