Kabeh Flowchart

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 18

3.

3 Perencanaan Sistem

Gambar 3.4 Flowchart Sistem Utama

Gambar 3.5 Subsistem Pasteurisasi

Gambar 3.6 Perencanaa Subsistem Pilihan Rasa

Gambar 3.7 Perencanaan Subsistem Pengisian Rasa

Gambar 3.8 Perencanaan Pengisian Susu

#include <NewPing.h>
#define TRIGGER_PIN 12 // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN

13 // Arduino pin tied to echo pin on the ultrasonic sensor.

#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in


centimeters). Maximum sensor distance is rated at 400-500cm.
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup
of pins and maximum distance.
int tinggi;
int jarak;

#include <OneWire.h>
int DS18S20_Pin = 11; //DS18S20 Signal pin on digital 2
OneWire ds(DS18S20_Pin); // on digital pin 2
float temperature=0;
#include <LiquidCrystal.h> //include the library code:
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);// initialize the library with the numbers of the
interface pins

byte customChar[8] = {
0b11000,
0b11000,
0b00111,
0b01000,
0b01000,
0b01000,

0b00111,
0b00000
};

#include <Servo.h>
Servo myservo;
int pos = 0;

#define relay_kompor
#define relay_servo

14
15

#define relay_strawberry 16
#define relay_coklat
#define relay_melon
#define relay_susu

17
18
19

#define ok 8
#define up 9

byte count_menu=0;
String rasa;

void setup(void) {
lcd.createChar(0, customChar);
pinMode(ok,INPUT_PULLUP);

pinMode(up,INPUT_PULLUP);

pinMode(relay_kompor,OUTPUT);
pinMode(relay_servo,OUTPUT);
pinMode(relay_strawberry,OUTPUT);
pinMode(relay_coklat,OUTPUT);
pinMode(relay_melon,OUTPUT);
pinMode(relay_susu,OUTPUT);

digitalWrite(relay_kompor,1);
digitalWrite(relay_servo,1);
digitalWrite(relay_strawberry,1);
digitalWrite(relay_coklat,1);
digitalWrite(relay_melon,1);
digitalWrite(relay_susu,1);

digitalWrite(relay_servo,1);
myservo.attach(10);

Serial.begin(9600);
lcd.begin(16, 2); // set up the LCD's number of columns and rows:
lcd.print("welcome"); // Print a message to the LCD.
delay(1000);

lcd.clear();
}

void loop(void) {

lcd.setCursor(0,0);
lcd.print("stanby"); lcd.print("

");

temperature = getTemp();
Serial.println(temperature);
lcd.setCursor(0,1);
lcd.print("suhu :"); lcd.print(temperature);lcd.print("
");lcd.write((uint8_t)0);lcd.print(" ");

if(digitalRead(ok)==LOW && temperature>40){


do{delay(100);}while(digitalRead(ok)==LOW);
lcd.clear();
menu();}

if(digitalRead(ok)==LOW && temperature<40){


do{delay(100);}while(digitalRead(ok)==LOW);
Serial.println("ok");

lcd.clear();

do{
temperature = getTemp();
lcd.setCursor(0,0);
lcd.print("kompor aktif");
lcd.setCursor(0,1);
lcd.print("suhu :"); lcd.print(temperature);lcd.print(" ");lcd.write((uint8_t)0);
lcd.print(" ");
digitalWrite(relay_kompor,0);
}while(temperature<62);

digitalWrite(relay_kompor,1);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("kompor mati");
delay(3000);
menu();
}
}

void menu(){
do{

if(digitalRead(up)==LOW){
do{
delay(50);

}while(digitalRead(up)==LOW);
Serial.println("up");count_menu++;
if(count_menu==3){count_menu=0;}}

if(count_menu==0){rasa="coklat";}
if(count_menu==1){rasa="melon";}
if(count_menu==2){rasa="strawberry";}

lcd.setCursor(0,0);
lcd.print("pilihan rasa");
lcd.setCursor(0,1);
lcd.print(rasa); lcd.print("

");

}while(digitalRead(ok)==HIGH);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("rasa yg dipilih");
lcd.setCursor(0,1);
lcd.print(rasa);
delay(3000);
lcd.clear();

delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("isi rasa");

if(rasa=="coklat"){
digitalWrite(relay_servo,0);
myservo.write(95);
delay(500);
digitalWrite(relay_servo,1);
delay(1000);
//-----------------------------------------do{
digitalWrite(relay_coklat,0);
ambil_jarak();
lcd.setCursor(0,0);
lcd.print("tinggi pengisian");
lcd.setCursor(0,1);
lcd.print("rasa :");lcd.print(tinggi);lcd.print(" "); lcd.print("cm");
}while(tinggi<3); digitalWrite(relay_coklat,1);

digitalWrite(relay_susu,0);
do{
ambil_jarak();

lcd.setCursor(0,0);
lcd.print("tinggi pengisian");
lcd.setCursor(0,1);
lcd.print("susu :");lcd.print(tinggi);lcd.print(" ");lcd.print("cm");

}while(tinggi<9);
digitalWrite(relay_susu,1);
//-----------------------------------------}

if(rasa=="melon"){
digitalWrite(relay_servo,0);
myservo.write(65);
delay(500);
digitalWrite(relay_servo,1);
delay(1000);

//-----------------------------------------do{
digitalWrite(relay_melon,0);
ambil_jarak();
lcd.setCursor(0,0);
lcd.print("tinggi pengisian");
lcd.setCursor(0,1);

lcd.print("rasa :");lcd.print(tinggi);lcd.print(" ");lcd.print("cm");


}while(tinggi<3); digitalWrite(relay_melon,1);

digitalWrite(relay_susu,0);
do{
ambil_jarak();
lcd.setCursor(0,0);
lcd.print("tinggi pengisian");
lcd.setCursor(0,1);
lcd.print("susu :");lcd.print(tinggi);lcd.print(" ");lcd.print("cm");

}while(tinggi<9);
digitalWrite(relay_susu,1);
//-----------------------------------------}

if(rasa=="strawberry"){
digitalWrite(relay_servo,0);
myservo.write(123);
delay(500);
digitalWrite(relay_servo,1);
delay(1000);

//------------------------------------------

do{
digitalWrite(relay_strawberry,0);
ambil_jarak();
lcd.setCursor(0,0);
lcd.print("tinggi pengisian");
lcd.setCursor(0,1);
lcd.print("rasa :");lcd.print(tinggi);lcd.print(" ");lcd.print("cm");
}while(tinggi<3); digitalWrite(relay_strawberry,1);

digitalWrite(relay_susu,0);
do{
ambil_jarak();
lcd.setCursor(0,0);
lcd.print("tinggi pengisian");
lcd.setCursor(0,1);
lcd.print("susu :");lcd.print(tinggi);lcd.print(" ");lcd.print("cm");

}while(tinggi<9);
digitalWrite(relay_susu,1);
//-----------------------------------------}

lcd.clear();
lcd.setCursor(0,0);

lcd.print("ready to drink");
delay(3000);
lcd.clear();

void ambil_jarak() {
delay(500);
// Wait 50ms between pings (about 20 pings/sec). 29ms
should be the shortest delay between pings.
unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS).
jarak=uS / US_ROUNDTRIP_CM;
tinggi=14-jarak;
if(tinggi<0){ambil_jarak();}
}

float getTemp(){
//returns the temperature from one DS18S20 in DEG Celsius

byte data[12];
byte addr[8];

if ( !ds.search(addr)) {
//no more sensors on chain, reset search
ds.reset_search();
return -1000;
}

if ( OneWire::crc8( addr, 7) != addr[7]) {


Serial.println("CRC is not valid!");
return -1000;
}

if ( addr[0] != 0x10 && addr[0] != 0x28) {


Serial.print("Device is not recognized");
return -1000;
}

ds.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end

byte present = ds.reset();


ds.select(addr);
ds.write(0xBE); // Read Scratchpad

for (int i = 0; i < 9; i++) { // we need 9 bytes


data[i] = ds.read();
}

ds.reset_search();

byte MSB = data[1];


byte LSB = data[0];

float tempRead = ((MSB << 8) | LSB); //using two's compliment


float TemperatureSum = tempRead / 16;

return TemperatureSum;

You might also like