|
以下是我的程式碼:
- #include <SPI.h>
- #include <Ethernet.h>
- byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
- char server[] = "docs.google.com";
- IPAddress ip = (192, 168, 0, 107);
- //IPAddress subnet = (,,,);
- //IPAddress gateway = (,,,);
- //IPAddress DNS = (,,,);
- EthernetClient client;
- void setup()
- {
- Serial.begin(9600);
- if (Ethernet.begin(mac) == 0) {
- Serial.println("Failed to configure Ethernet using DHCP");
- Ethernet.begin(mac, ip);
- }
- delay(1000);
- Serial.println("connecting...");
- if (client.connect(server, 80)) {
- Serial.println("connected");
- client.print("GET /forms/d/1R7-wmVhXuPWXnQ2RKimmwC6OGktYoCydRNPDZr7VpZ0/formResponse?ifq&entry.1757053596=Night&entry.1374568256=30&submit=Submit HTTP/1.1");
- client.println("Host: docs.google.com");
- client.println("Connection: close");
- client.println();
- Serial.print("GET /forms/d/1R7-wmVhXuPWXnQ2RKimmwC6OGktYoCydRNPDZr7VpZ0/formResponse?ifq&entry.1757053596=Night&entry.1374568256=30&submit=Submit HTTP/1.1");
- Serial.println("Host: docs.google.com");
- Serial.println("Connection: close");
- Serial.println();
- }
- }
- void loop()
- {
- if (client.available()) {
- char c = client.read();
- Serial.print(c);
- }
- if (!client.connected()) {
- Serial.println();
- Serial.println("disconnecting.");
- client.stop();
- while (true);
- }
- }
複製代碼 |
|