Advertisement
Guest User

Untitled

a guest
May 26th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
  28.  
  29. void loop() {
  30. String postData = "card=1&function=2";
  31.  
  32. if (client.connect("192.168.0.10", 80)) {
  33. Serial.println("Connected to server");
  34. // Make a HTTP request
  35. String content = "Hey, just testing a post request.";
  36. client.println("POST /tat/arduino/add_data.php HTTP/1.1");
  37. client.println("Host: 192.168.0.10:80");
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement