Advertisement
kubbur

Untitled

Mar 19th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.55 KB | None | 0 0
  1. #include <SPI.h>
  2. #include <Ethernet.h>
  3. #include <Servo.h>
  4.  
  5. byte mac[] = { 0x90, 0xa2, 0xda, 0x0d, 0x7c, 0xa9 }; //physical mac address 90-a2-da-0d-7c-a9
  6. byte ip[] = { 192, 168, 1, 178 }; // ip in lan (that's what you need to use in your browser. ("192.168.1.178")
  7. byte gateway[] = { 192, 168, 1, 254 }; // internet access via router
  8. byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
  9. EthernetServer server(1432); //server port
  10. String readString;
  11.  
  12. servo servo1;
  13. int analogpin = 1;
  14.  
  15. void setup()
  16. { //serialbegin, pinmode, servo, ethernet, startingsound
  17. Serial.begin(9600);
  18. pinMode(3, OUTPUT);
  19. servo1.attach(7);
  20.  
  21. Ethernet.begin(mac, ip, gateway, subnet);
  22. server.begin();
  23. Serial.print("server is at ");
  24. Serial.println(Ethernet.localIP());
  25.  
  26. //startingsound
  27. tone (3, 800, 100);
  28. delay (200);
  29. tone (3, 800, 100);
  30. delay (200);
  31. tone (3, 800, 100);
  32. delay (200);
  33. }
  34. void loop1() //default position
  35. {
  36. servo1.write(90);
  37. delay (200);
  38. }
  39. void loop2() //coffie machine on
  40. {
  41. servo1.write (64);
  42. delay (200);
  43. }
  44. void loop3 //waiting for water to heat
  45. {
  46. delay (100000)
  47. }
  48. void loop4 //pushing the cup button
  49. {
  50. servo1.write (118);
  51. delay(200)
  52. }
  53. void loop5
  54. {
  55. delay (30000) //waiting while coffie is pouring
  56. tone (3, 800, 200)
  57. delay (200)
  58. tone (3, 800, 200)
  59. int changepad = 1;
  60. void loop()
  61. {
  62. EthernetClient client = server.availible();
  63. if (client)
  64. {
  65. while (client.connected())
  66. {
  67. if (client.availible())
  68. {
  69. char c = client.reada();
  70. if (readString.length() < 100)
  71. {
  72. readstring += c;
  73. }
  74.  
  75. if (c == '\n')
  76. {
  77. client.println("HTTP/1.1 200 OK"); //send new page
  78. client.println("Content-Type: text/html; charset=utf-8");
  79. client.println();
  80. client.println("<HTML>");
  81. client.println("<HEAD>");
  82. client.println("<meta name='apple-mobile-web-app-capable' content='yes' />");
  83. client.println("<meta name='apple-mobile-web-app-status-bar-style' content='black-translucent' />");
  84. client.println("<link rel='stylesheet' type='text/css' href='http://randomnerdtutorials.com/ethernetcss.css' />");
  85. client.println("<TITLE>kubburs automatic coffie machine</TITLE>");
  86. client.println("</HEAD>");
  87. client.println("<BODY>");
  88. client.println("<H1>kubburs automatic coffie machine</H1>");
  89. client.println("<hr />");
  90. client.println("<br />");
  91. client.println("<H2>Arduino with Ethernet Shield</H2>");
  92. client.println("<br />");
  93. client.println("<a href=\"/?button1\"\">Turn on/off coffie machine</a>");
  94. client.println("<a href=\"/?button2\"\">Pour coffie</a><br />");
  95. client.println("<br />");
  96. client.println("<br />");
  97. client.println("<a href=\"/?button3\"\">make me a coffie</a>");
  98. client.println("<a href=\"/?button4\"\">make me 2 coffies</a><br />");
  99. client.println("<br />");
  100. client.println("<br />");
  101. client.println("<a href=\"/?button5\"\">make me 3 coffies</a>");
  102. client.println("<a href=\"/?button6\"\">piezo element</a><br />");
  103. client.println("</BODY>");
  104. client.println("</HTML>");
  105.  
  106. delay(1);
  107. client.stop();
  108.  
  109. val = analogRead(analogPin);
  110. int changepad;
  111.  
  112. if (val > 100)
  113. {
  114. int changepad = 0;
  115. }
  116.  
  117. if (readString.indexOf("?button1") > 0 && changepad == 0 && val == 0)
  118. {
  119. loop1();
  120. loop2();
  121. loop1();
  122. loop3();
  123. loop4();
  124. loop1();
  125. loop5();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement