Translate

Membuat Water Mixer / Alat Pencampur Minuman / Cairan Menggunakan Arduino WIFI Ethernet Shield

Membuat Water Mixer / Alat Pencampur Minuman / Cairan Menggunakan Arduino WIFI Ethernet Shield


        Pada kesempatan kali ini saya akan membahas mengenai bagaimana cara membuat sebuah alat yang digunakan untuk mencampur minuman atau cairan, misalnya terdapat susu, teh, gula dan kopi, kemudian si pembeli ingin memesan kopi susu sehingga yang akan keluar dari alat adalah gula, kopi dan susu, begitu pula dengan menu yang lain seperti teh susu atau kopi / teh manis. yang menarik dari alat ini adalah si pembeli bisa memesan dengan dua cara yaitu bisa dengan manual atau tombol, selain itu pembeli juga bisa memesan melalui handphone mereka atau komputer yang terhubung ke sebuah router yang sama dengan alat ini, komunikasinya menggunakan wifi. untuk lebih jelasnya berikut adalah skema dan programnya.




a. Arduino + Ethernet Shield





b. Solenoid Valve 1/2 dim





c. UBEC 3A maks 5A





d. Router WIFI





e. LCD 20x4





f. Program Arduino IDE

#include "Wire.h"
#include <LiquidCrystal.h>
#include <SPI.h>
#include <Ethernet.h>

LiquidCrystal lcd(A8, A9, A13, A12, A11, A10);

byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,0,99);

EthernetServer server(80);

String readString;
int a;
int b;
int c;
int d;


void setup() {

  lcd.begin(20, 4);
  lcd.clear();
  lcd.noCursor();

//A0 = RELAY1 = KOPI
//A1 = RELAY2 = SUSU
//A2 = RELAY3 = TEH
//A3 = RELAY4 = GULA
 
pinMode(A0,OUTPUT);;
pinMode(A1,OUTPUT);;
pinMode(A2,OUTPUT);;
pinMode(A3,OUTPUT);;

pinMode(18,INPUT);;
pinMode(19,INPUT);;
pinMode(20,INPUT);;
pinMode(21,INPUT);;

digitalWrite(18,HIGH);
digitalWrite(19,HIGH);
digitalWrite(20,HIGH);
digitalWrite(21,HIGH);

//digitalWrite(A0,HIGH);
//digitalWrite(A1,HIGH);
//digitalWrite(A2,HIGH);
//digitalWrite(A3,HIGH);

 
  Serial.begin(9600);
   while (!Serial) {
  }

  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}

void loop() {

  EthernetClient client = server.available();
  if (client) {
   
   
  lcd.setCursor(3, 0);
  lcd.print("ANDRE CAFE MENU");
  lcd.setCursor(0, 1);
  lcd.print("1.KOPI");
  lcd.setCursor(0, 2);
  lcd.print("2.TEH");
  lcd.setCursor(0, 3);
  lcd.print("3.SUSU");

   
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
     if (readString.length() < 100) {

          //store characters to string
          readString += c;
          //Serial.print(c);
        }
        if (c == '\n' && currentLineIsBlank) {
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          client.println(" ");
          client.println("<title> Andre Cafe </title> ");    
          client.println("<body bgcolor = #000000>");    
          client.println("<left>");
            client.println("<font color = yellow><center><h1>DAFTAR MENU MINUMAN ANDRE CAFE</h1></center><br></font>");
            client.println("<font color = #FFFFFF>");                 
          client.println("<h2>KOPI :</h2>");
          client.println("<br>");
          //client.println("<center");
          client.println("<a href = \"/?lighton1\"\"><input type = 'button' value = 'KOPI' ></a>");
          client.println("<a href = \"/?lighton2\"\"><input type = 'button' value = 'KOPI HITAM' ></a> ");
          client.println("<a href = \"/?lighton3\"\"><input type = 'button' value = 'KOPI SUSU' ></a> ");
          //client.println("</center");
          client.println("<br>");
          client.println("<br>");
          client.println("<h2>TEH :</h2>");
          client.println("<br>");
          //client.println("<center");
          client.println("<a href = \"/?lighton4\"\"><input type = 'button' value = 'TEH ' ></a>");
          client.println("<a href = \"/?lighton5\"\"><input type = 'button' value = 'TEH TARIK' ></a> ");
          client.println("<a href = \"/?lighton6\"\"><input type = 'button' value = 'TEH MANIS ' ></a> ");
          //client.println("</center");
          client.println("<br>");
          client.println("<br>");
          client.println("<h2>SUSU :</h2>");
          client.println("<br>");
          //client.println("<center");
          client.println("<a href = \"/?lighton7\"\"><input type = 'button' value = 'SUSU MANIS' ></a> ");
          client.println("<a href = \"/?lighton8\"\"><input type = 'button' value = 'SUSU TAWAR' ></a> ");
          //client.println("</center");
          client.println("<br>");
          client.println("</left>");
          client.println("</body>");
          client.println("</html>");
           
          break;      
        }   
        if (c == '\n') {
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          currentLineIsBlank = false;
        }
      }
    }
    delay(1);
    client.stop();
    Serial.println("client disonnected");
  }
          //kopi
          if(readString.indexOf("?lighton1") >0)
          {
            //gula
            digitalWrite(A3,HIGH);
            delay(1000);
            digitalWrite(A3,LOW);
            delay(1000);
            //kopi
            digitalWrite(A0,HIGH);
            delay(1000);
            digitalWrite(A0,LOW);
            delay(1000);       
           
          }
   
          if(readString.indexOf("?lighton2") >0)
          {

            //kopi
            digitalWrite(A0,HIGH);
            delay(1000);
            digitalWrite(A0,LOW);
            delay(1000);       


          }         
         
          if(readString.indexOf("?lighton3") >0)
          {

            //gula
            digitalWrite(A3,HIGH);
            delay(1000);
            digitalWrite(A3,LOW);
            delay(1000);
            //kopi
            digitalWrite(A0,HIGH);
            delay(1000);
            digitalWrite(A0,LOW);
            delay(1000);       
            //susu
            digitalWrite(A1,HIGH);
            delay(1000);
            digitalWrite(A1,LOW);
            delay(1000);

          } 
        
        
          if(readString.indexOf("?lighton4") >0)
          {

            //teh
            digitalWrite(A2,HIGH);
            delay(1000);
            digitalWrite(A2,LOW);
            delay(1000);       
 
          } 
         
         
          if(readString.indexOf("?lighton5") >0)
          {
           
            //gula
            digitalWrite(A3,HIGH);
            delay(1000);
            digitalWrite(A3,LOW);
            delay(1000);
            //teh
            digitalWrite(A2,HIGH);
            delay(1000);
            digitalWrite(A2,LOW);
            delay(1000);       
            //susu
            digitalWrite(A1,HIGH);
            delay(1000);
            digitalWrite(A1,LOW);
            delay(1000);

          } 
         
         
          if(readString.indexOf("?lighton6") >0)
          {

            //gula
            digitalWrite(A3,HIGH);
            delay(1000);
            digitalWrite(A3,LOW);
            delay(1000);       
            //teh
            digitalWrite(A2,HIGH);
            delay(1000);
            digitalWrite(A2,LOW);
            delay(1000);

          }
        
        
          if(readString.indexOf("?lighton7") >0)
          {

            //gula
            digitalWrite(A3,HIGH);
            delay(1000);
            digitalWrite(A3,LOW);
            delay(1000);       
            //susu
            digitalWrite(A1,HIGH);
            delay(1000);
            digitalWrite(A1,LOW);
            delay(1000);

          } 
         
         
          if(readString.indexOf("?lighton8") >0)
          {

            //susu
            digitalWrite(A1,HIGH);
            delay(1000);
            digitalWrite(A1,LOW);
            delay(1000);

          } 

a = digitalRead(19);
b = digitalRead(18);
c = digitalRead(20);
d = digitalRead(21);

 if(a == LOW){
 lcd.clear();
delay(500);
   menu1();
 }

 if(b == LOW){
 lcd.clear();
delay(500);
   menu2();  
 }

 if(c == LOW){
 lcd.clear();
delay(500);
   menu3();  
 }

if(d == LOW){

 lcd.clear();
    
  lcd.setCursor(3, 0);
  lcd.print("ANT CAFE MENU");
  lcd.setCursor(0, 1);
  lcd.print("1.KOPI");
  lcd.setCursor(0, 2);
  lcd.print("2.TEH");
  lcd.setCursor(0, 3);
  lcd.print("3.SUSU");

    
 }

 
         
         
         readString="";

}




void menu1(){

// lcd.clear();
a = digitalRead(19);
b = digitalRead(18);
c = digitalRead(20);
d = digitalRead(21);
    
  lcd.setCursor(3, 0);
  lcd.print("Menu Kopi");
  lcd.setCursor(0, 1);
  lcd.print("1.Kopi Hitam Manis");
  lcd.setCursor(0, 2);
  lcd.print("2.Kopi Hitam");
  lcd.setCursor(0, 3);
  lcd.print("3.Kopi Susu");
 
  if(d == LOW){
  return;
  }
 
  if(a == 0){
 
              //gula
            digitalWrite(A3,HIGH);
            delay(1000);
            digitalWrite(A3,LOW);
            delay(1000);
            //kopi
            digitalWrite(A0,HIGH);
            delay(1000);
            digitalWrite(A0,LOW);
            delay(1000);       
  }
    if(b == 0){
 
            //kopi
            digitalWrite(A0,HIGH);
            delay(1000);
            digitalWrite(A0,LOW);
            delay(1000);       
  }
    if(c == 0){
 
            //gula
            digitalWrite(A3,HIGH);
            delay(1000);
            digitalWrite(A3,LOW);
            delay(1000);
            //kopi
            digitalWrite(A0,HIGH);
            delay(1000);
            digitalWrite(A0,LOW);
            delay(1000);
            //susu
            digitalWrite(A1,HIGH);
            delay(1000);
            digitalWrite(A1,LOW);
            delay(1000);      
  }
 
menu1();
}




void menu2(){
   //lcd.clear();
a = digitalRead(19);
b = digitalRead(18);
c = digitalRead(20);
d = digitalRead(21);
    
  lcd.setCursor(3, 0);
  lcd.print("Menu Teh");
  lcd.setCursor(0, 1);
  lcd.print("1.Teh");
  lcd.setCursor(0, 2);
  lcd.print("2.Teh Tarik");
  lcd.setCursor(0, 3);
  lcd.print("3.Teh Manis");
 
  if (a == 0){
 
            //teh
            digitalWrite(A2,HIGH);
            delay(1000);
            digitalWrite(A2,LOW);
            delay(1000);   
  }

  if (b == 0){
 
              //gula
            digitalWrite(A3,HIGH);
            delay(1000);
            digitalWrite(A3,LOW);
            delay(1000);
            //teh
            digitalWrite(A2,HIGH);
            delay(1000);
            digitalWrite(A2,LOW);
            delay(1000);       
            //susu
            digitalWrite(A1,HIGH);
            delay(1000);
            digitalWrite(A1,LOW);
            delay(1000);
   
  }
 
    if (c == 0){
 
              //gula
            digitalWrite(A3,HIGH);
            delay(1000);
            digitalWrite(A3,LOW);
            delay(1000);
            //teh
            digitalWrite(A2,HIGH);
            delay(1000);
            digitalWrite(A2,LOW);
            delay(1000);       
           
   
  }
 
 
if(d == LOW){
  return;
  }
 
menu2();

}



void menu3(){
  //lcd.clear();
a = digitalRead(19);
b = digitalRead(18);
c = digitalRead(20);
d = digitalRead(21);
    
  lcd.setCursor(3, 0);
  lcd.print("Menu Susu");
  lcd.setCursor(0, 1);
  lcd.print("1.Susu Manis");
  lcd.setCursor(0, 2);
  lcd.print("2.Susu Tawar");

if(a == 0){
            //gula
            digitalWrite(A3,HIGH);
            delay(1000);
            digitalWrite(A3,LOW);
            delay(1000);       
            //susu
            digitalWrite(A1,HIGH);
            delay(1000);
            digitalWrite(A1,LOW);
            delay(1000);
}

if(b == 0){
        //susu
            digitalWrite(A1,HIGH);
            delay(1000);
            digitalWrite(A1,LOW);
            delay(1000);
}


if(d == LOW){
  return;
  }
 
menu3();

}





g. VIDEO HASILNYA









No comments:

Post a Comment