Translate

Restaurant Ordering System Using Arduino and Proteus

Restaurant Ordering System Using Arduino and Proteus


         Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang digunakan untuk melalukan order makanan minuman dan dessert. jadi alat ini hanyalah simulasi dengan menggunakan software proteus 7. jadi simulasi alat ini menggunakan 3 buah push button untuk memilih pilihan yang tersedia dan ada satu buah tombol untuk resetnya. untuk lebih jelasnya berikut adalah koding dan skemanya.



a. Skema Simulasi Alat




b. Program Arduino IDE

#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x20, 20, 4);

//mosi - 11
//miso - 12
//clk - 13
//cs - 4
File myFile;

int btmenu1 = 2;
int btmenu2 = 3;
int btmenu3 = 5;
int btmenu1x;
int btmenu2x;
int btmenu3x;
int cmenu1;
int cmenu2;
int cmenu3;

void setup() {

  pinMode(btmenu1,INPUT_PULLUP);
  pinMode(btmenu2,INPUT_PULLUP);
  pinMode(btmenu3,INPUT_PULLUP);
 
  Serial.begin(9600);
  lcd.begin();
  lcd.clear();
  lcd.noCursor();

}

void loop() {
menu1();
delay(200);
lcd.clear();
menu2();
delay(200);
lcd.clear();
menu3();
delay(200);
lcd.clear();
greeting();
lcd.clear();
delay(200);
}

void menu1(){
  
btmenu1x = digitalRead(btmenu1);
btmenu2x = digitalRead(btmenu2);
btmenu3x = digitalRead(btmenu3);

lcd.setCursor(0,0);
lcd.print("Choose Food ");
lcd.setCursor(0,1);
lcd.print("1. Chicken  ");
lcd.setCursor(0,2);
lcd.print("2. Burger   ");
lcd.setCursor(0,3);
lcd.print("3. Pizza    ");
   
if(btmenu1x == 0){
cmenu1 = 1;
return;
}

if(btmenu2x == 0){
cmenu1 = 2;
return;
}

if(btmenu3x == 0){
cmenu1 = 3;
return;
}

menu1();
}

void menu2(){
  
btmenu1x = digitalRead(btmenu1);
btmenu2x = digitalRead(btmenu2);
btmenu3x = digitalRead(btmenu3);

lcd.setCursor(0,0);
lcd.print("Choose Drink   ");
lcd.setCursor(0,1);
lcd.print("1. Tea  ");
lcd.setCursor(0,2);
lcd.print("2. Lemon Tea   ");
lcd.setCursor(0,3);
lcd.print("3. Milk       ");
   
if(btmenu1x == 0){
cmenu2 = 1;
return;
}

if(btmenu2x == 0){
cmenu2 = 2;
return;
}

if(btmenu3x == 0){
cmenu2 = 3;
return;
}

menu2();
}

void menu3(){
  
btmenu1x = digitalRead(btmenu1);
btmenu2x = digitalRead(btmenu2);
btmenu3x = digitalRead(btmenu3);

lcd.setCursor(0,0);
lcd.print("Choose Fruit   ");
lcd.setCursor(0,1);
lcd.print("1. Manggo  ");
lcd.setCursor(0,2);
lcd.print("2. Orange   ");
lcd.setCursor(0,3);
lcd.print("3. Grape      ");
   
if(btmenu1x == 0){
cmenu3 = 1;
return;
}

if(btmenu2x == 0){
cmenu3 = 2;
return;
}

if(btmenu3x == 0){
cmenu3 = 3;
return;
}

menu3();
}

void greeting(){
  
Serial.print("Order Menu1: ");  
Serial.println(cmenu1);
Serial.print("Order Menu2: ");
Serial.println(cmenu2);
Serial.print("Order Menu3: ");
Serial.println(cmenu3);

lcd.setCursor(0,0);
lcd.print("Thankyou for order");
lcd.setCursor(0,1);
lcd.print("Please wait");
lcd.setCursor(0,2);
lcd.print("Save to SD");
delay(1000);
savetosd();
}

void savetosd(){

while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  //Serial.print("Initializing SD card...");
  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
  // Note that even if it's not used as the CS pin, the hardware SS pin 
  // (10 on most Arduino boards, 53 on the Mega) must be left as an output
  // or the SD library functions will not work.
  pinMode(10, OUTPUT);

  if (!SD.begin(4)) {
    //Serial.println("initialization failed!");
    return;
  }
  //Serial.println("initialization done.");

  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  myFile = SD.open("test.txt", FILE_WRITE);

  // if the file opened okay, write to it:
  if (myFile) {
     
    myFile.print("choose1= ");
    myFile.println(cmenu1);
    myFile.print("choose2= ");
    myFile.println(cmenu2);
    myFile.print("choose3= ");
    myFile.println(cmenu2);
     
    // close the file:
    myFile.close();
    //Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    //Serial.println("error opening test.txt");
  }

}




c. VIDEO HASILNYA





No comments:

Post a Comment