~ubuntu-branches/ubuntu/precise/arduino/precise

« back to all changes in this revision

Viewing changes to libraries/Ethernet/examples/WebClient/WebClient.pde

  • Committer: Bazaar Package Importer
  • Author(s): Scott Howard
  • Date: 2010-04-13 22:32:24 UTC
  • Revision ID: james.westby@ubuntu.com-20100413223224-jduxnd0xxnkkda02
Tags: upstream-0018+dfsg
ImportĀ upstreamĀ versionĀ 0018+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <Ethernet.h>
 
2
 
 
3
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
 
4
byte ip[] = { 10, 0, 0, 177 };
 
5
byte server[] = { 64, 233, 187, 99 }; // Google
 
6
 
 
7
Client client(server, 80);
 
8
 
 
9
void setup()
 
10
{
 
11
  Ethernet.begin(mac, ip);
 
12
  Serial.begin(9600);
 
13
  
 
14
  delay(1000);
 
15
  
 
16
  Serial.println("connecting...");
 
17
  
 
18
  if (client.connect()) {
 
19
    Serial.println("connected");
 
20
    client.println("GET /search?q=arduino HTTP/1.0");
 
21
    client.println();
 
22
  } else {
 
23
    Serial.println("connection failed");
 
24
  }
 
25
}
 
26
 
 
27
void loop()
 
28
{
 
29
  if (client.available()) {
 
30
    char c = client.read();
 
31
    Serial.print(c);
 
32
  }
 
33
  
 
34
  if (!client.connected()) {
 
35
    Serial.println();
 
36
    Serial.println("disconnecting.");
 
37
    client.stop();
 
38
    for(;;)
 
39
      ;
 
40
  }
 
41
}