SHOW:
|
|
- or go back to the newest paste.
1 | #include <SPI.h> | |
2 | #include <Ethernet.h> | |
3 | #include <MFRC522.h> | |
4 | #include <Wire.h> | |
5 | #include <LiquidCrystal_I2C.h> | |
6 | #include <Keypad.h> | |
7 | ||
8 | LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address | |
9 | ||
10 | /******************** ETHERNET SETTINGS ********************/ | |
11 | /* W500 Module */ | |
12 | byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x85, 0xD9 }; //physical mac address | |
13 | byte ip[] = { 192, 168, 0, 223 }; // ip in lan | |
14 | byte subnet[] = { 255, 255, 255, 0 }; //subnet mask | |
15 | byte gateway[] = { 192, 168, 0, 1 }; // default gateway | |
16 | byte server[] = { 192, 168, 0, 10}; | |
17 | EthernetClient client; | |
18 | ||
19 | void setup() | |
20 | { | |
21 | Serial.begin(9600); | |
22 | Serial.println("Starting up"); | |
23 | lcd.begin(20, 4); | |
24 | ||
25 | Ethernet.begin(mac, ip, gateway, subnet); // initialize Ethernet device | |
26 | } | |
27 | - | client.connect(server, 80); |
27 | + | |
28 | - | delay(1000); |
28 | + | |
29 | void loop() { | |
30 | - | Serial.println("Connecting..."); |
30 | + | |
31 | ||
32 | - | if (client.connected()) { |
32 | + | |
33 | - | Serial.println("Connected"); |
33 | + | |
34 | - | |
34 | + | |
35 | - | } else { |
35 | + | |
36 | - | Serial.println("connection failed"); |
36 | + | |
37 | - | } |
37 | + | |
38 | client.println("User-Agent: Arduino/1.0"); | |
39 | client.println("Content-Type: application/x-www-form-urlencoded"); | |
40 | client.print("Content-Length: "); | |
41 | client.print(postData.length()); | |
42 | client.println("Accept: */*"); | |
43 | client.println(); | |
44 | client.println(content); | |
45 | ||
46 | } else { | |
47 | Serial.println("Connect failed"); | |
48 | } | |
49 | ||
50 | delay(1500); | |
51 | } |