Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPI.h>
- #include <Ethernet.h>
- #include <Servo.h>
- byte mac[] = { 0x90, 0xa2, 0xda, 0x0d, 0x7c, 0xa9 }; //physical mac address 90-a2-da-0d-7c-a9
- byte ip[] = { 192, 168, 1, 178 }; // ip in lan (that's what you need to use in your browser. ("192.168.1.178")
- byte gateway[] = { 192, 168, 1, 254 }; // internet access via router
- byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
- EthernetServer server(1432); //server port
- String readString;
- servo servo1;
- int analogpin = 1;
- void setup()
- { //serialbegin, pinmode, servo, ethernet, startingsound
- Serial.begin(9600);
- pinMode(3, OUTPUT);
- servo1.attach(7);
- Ethernet.begin(mac, ip, gateway, subnet);
- server.begin();
- Serial.print("server is at ");
- Serial.println(Ethernet.localIP());
- //startingsound
- tone (3, 800, 100);
- delay (200);
- tone (3, 800, 100);
- delay (200);
- tone (3, 800, 100);
- delay (200);
- }
- void loop1() //default position
- {
- servo1.write(90);
- delay (200);
- }
- void loop2() //coffie machine on
- {
- servo1.write (64);
- delay (200);
- }
- void loop3 //waiting for water to heat
- {
- delay (100000)
- }
- void loop4 //pushing the cup button
- {
- servo1.write (118);
- delay(200)
- }
- void loop5
- {
- delay (30000) //waiting while coffie is pouring
- tone (3, 800, 200)
- delay (200)
- tone (3, 800, 200)
- int changepad = 1;
- void loop()
- {
- EthernetClient client = server.availible();
- if (client)
- {
- while (client.connected())
- {
- if (client.availible())
- {
- char c = client.reada();
- if (readString.length() < 100)
- {
- readstring += c;
- }
- if (c == '\n')
- {
- client.println("HTTP/1.1 200 OK"); //send new page
- client.println("Content-Type: text/html; charset=utf-8");
- client.println();
- client.println("<HTML>");
- client.println("<HEAD>");
- client.println("<meta name='apple-mobile-web-app-capable' content='yes' />");
- client.println("<meta name='apple-mobile-web-app-status-bar-style' content='black-translucent' />");
- client.println("<link rel='stylesheet' type='text/css' href='http://randomnerdtutorials.com/ethernetcss.css' />");
- client.println("<TITLE>kubburs automatic coffie machine</TITLE>");
- client.println("</HEAD>");
- client.println("<BODY>");
- client.println("<H1>kubburs automatic coffie machine</H1>");
- client.println("<hr />");
- client.println("<br />");
- client.println("<H2>Arduino with Ethernet Shield</H2>");
- client.println("<br />");
- client.println("<a href=\"/?button1\"\">Turn on/off coffie machine</a>");
- client.println("<a href=\"/?button2\"\">Pour coffie</a><br />");
- client.println("<br />");
- client.println("<br />");
- client.println("<a href=\"/?button3\"\">make me a coffie</a>");
- client.println("<a href=\"/?button4\"\">make me 2 coffies</a><br />");
- client.println("<br />");
- client.println("<br />");
- client.println("<a href=\"/?button5\"\">make me 3 coffies</a>");
- client.println("<a href=\"/?button6\"\">piezo element</a><br />");
- client.println("</BODY>");
- client.println("</HTML>");
- delay(1);
- client.stop();
- val = analogRead(analogPin);
- int changepad;
- if (val > 100)
- {
- int changepad = 0;
- }
- if (readString.indexOf("?button1") > 0 && changepad == 0 && val == 0)
- {
- loop1();
- loop2();
- loop1();
- loop3();
- loop4();
- loop1();
- loop5();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement