Perancangan Alat Sortir Buah Jeruk Berdasarkan Warna RGB dengan Mikrokontroller Arduino

LAMPIRAN A
PROGRAM MIKROKONTROLER ARDUINO UNO

A.1 SensorTCS3200.ino
#include
#include
#define S0 A0
#define S1 A1
#define S2 A2
#define S3 A3
#define sensorOut A4
#define button 9
Servo topServo;
Servo bottomServo;
//Stopwatch
long startTime;
long elapsedTime;
//Sorting
int frequency = 0;
int color = 0;
int i=0;

int R, G, B;
int kr[5], kg[5], kb[5];
int play = 0;
int orange, Khijau, hijau;
LiquidCrystal lcd(7, 6, 5, 4, 3, 2); //LCD
void tampil_LCD()
{
//LCD
lcd.clear();
lcd.setCursor(0,0);
lcd.print("R=");
lcd.print(R);
lcd.print(" G=");
lcd.print(G);
lcd.print(" B=");
lcd.print(B);
delay(100);
}
void kalibrasi()


Universitas Sumatera Utara

{
Serial.println("Kalibrasi warna");
Serial.println("Waiting...");
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Calibration");
for(i=0;iB)
{
if(abs(R-G)>50) return 4;
else return 5;
}

Universitas Sumatera Utara

}
}
void setup() {
pinMode(S0, OUTPUT);

pinMode(S1, OUTPUT);
pinMode(S2, OUTPUT);
pinMode(S3, OUTPUT);
pinMode(sensorOut, INPUT);
pinMode(button, INPUT);
digitalWrite(S0, HIGH);//setting frequency-scaling to
20%
digitalWrite(S1, LOW);
topServo.attach(11);
bottomServo.attach(12);
Serial.begin(9600);
lcd.begin(16,2);
lcd.clear();
lcd.setCursor(0,0);
}
void kondisiButton()
{
if(digitalRead(button)==HIGH)
{
if(!play) {play=true;}

else {play=false;}
delay(50);
//bouncing
}
}
void loop()
{
topServo.write(85);
bottomServo.write(100);
kondisiButton();
if(play)
{
lcd.clear();
lcd.print("Orange");
lcd.setCursor(6,0);
lcd.print(" KH");
lcd.setCursor(11,0);
lcd.print("Hijau");
lcd.setCursor(0,1);
lcd.print(orange);


Universitas Sumatera Utara

lcd.setCursor(7,1);
lcd.print(Khijau);
lcd.setCursor(12,1);
lcd.print(hijau);
}
else
{
startTime = millis ();
color = cek_warna();
elapsedTime = millis () - startTime;
}
switch (color)
{
case 1:
Serial.print("BIRU ");
break;


// Warna Dasar

case 2:
Serial.print("MERAH "); // Warna Dasar
break;
case 3:
tampil_LCD();
lcd.setCursor(0,1);
lcd.print("HIJAU");
Serial.println("HIJAU ");
Serial.println(" ");
hijau++;
delay(50);
topServo.write(120);
//Arah buah ke wadah hijau
break;
case 4:
tampil_LCD();
lcd.setCursor(0,1);
lcd.print("ORANGE");

Serial.println("ORANGE ");
Serial.println(" ");
orange++;
delay(50);
topServo.write(45);
// Arah Buah ke wadah orange
break;
case 5:
tampil_LCD();
lcd.setCursor(0,1);
lcd.print("KUNING-HIJAU");
Serial.println("KUNING-HIJAU ");
Serial.println(" ");

Universitas Sumatera Utara

Khijau++;
delay(50);
topServo.write(120);
// Arah Buah ke wadah hijau

bottomServo.write(45); // tutup wadah Hijau
break;
case 0:
break;
}
delay(250);
color = 0;
}
// custom function - readcolor()
int readcolor()
{
// Setting red filtered photodiodes to be read
digitalWrite(S2,LOW);
digitalWrite(S3,LOW);
// Reading the output frequency
frequency = pulseIn(sensorOut, LOW);
//Remaping frequency to the RGB Model of 0 to 255
frequency = map(frequency, 25,72,255,0);
R = frequency;
// Printing the value on the serial monitor

Serial.print("R= ");//printing name
Serial.print(frequency);//printing RED frequency
Serial.print(" ");
delay(50);
// Setting Green filtered photodiodes to be read
digitalWrite(S2,HIGH);
digitalWrite(S3,HIGH);
// Reading the output frequency
frequency = pulseIn(sensorOut, LOW);
//Remaping frequency to the RGB Model of 0 to 255
frequency = map(frequency, 30,90,255,0);
G = frequency;
// Printing the value on the serial monitor
Serial.print("G= ");//printing name
Serial.print(frequency);//printing Green frequency
Serial.print(" ");
delay(50);
// Setting Blue filtered photodiodes to be read
digitalWrite(S2,LOW);
digitalWrite(S3,HIGH);

// Reading the output frequency
frequency = pulseIn(sensorOut, LOW);
//Remaping frequency to the RGB Model of 0 to 255

Universitas Sumatera Utara

frequency = map(frequency, 25,70,255,0);
B = frequency;
// Printing the value on the serial monitor
Serial.print("B= ");//printing name
Serial.print(frequency);//printing Blue frequency
Serial.println(" ");
delay(50);
}

Universitas Sumatera Utara

LAMPIRAN B
GAMBAR FLOWCHART PEMOGRAMAN ARDUINO


B.1 Flowchart Pemograman Mikrokontroler Arduino.
Start

Inisialisasi Pin I/O
Servo, LCD,
TCS3200

C

Kondisikan
Servo dalam
keadaan
default

Baca kondisi
Push Button

If
play==true

A

Tidak

If
iB

Tidak

B

Ya

Ya

If
|R-G| > 50

Ya

Tidak

Ya
Return Color = 0

Return Color = 3

Return Color = 4

Return Color = 5

B

Universitas Sumatera Utara

B

If color ==1

If color == 2

If color == 3

If color == 4

If color == 5

Tampilkan
Warna Biru
pada LCD

Tampilkan
Warna
Merah pada
LCD

Tampilkan
Warna Hijau
pada LCD

Tampilkan
Warna
Orange pada
LCD

Tampilkan
Warna Kuning
Hijau pada
LCD

Servo Atas Ke arah
Kanan (120°)

Servo Atas ke arah
Kiri (45°)

Servo Atas ke arah
kanan (120°)
Servo Bawah ke
arah kanan (45°)

C

End

Universitas Sumatera Utara

CURRICULUM VITAE

DATA PRIBADI
Nama
Tempat, Tanggal Lahir
Jenis Kelamin
Agama
Kewarganegaraan
Alamat KTP

:
:
:
:
:
:

Fadly Tommy
Marjandi, 01 April 1994
Laki-Laki
Islam
Indonesia
Dusun V Emplasmen Pabatu, Tebing
Tinggi
: 081260624547
: fadly_tommy@yahoo.co.id

Telepon / HP
Email
PENDIDIKAN FORMAL

SEKOLAH /
FAKULTAS
UNIVERSITAS
Universitas
FMIPA
Sumatera Utara
SMAN 4
-

JURUSAN

KOTA

IPK

PERIODE
(TAHUN)

Teknik
Informatika
IPA

Medan

3,46

2011 - 2014

Tebing Tinggi

8,50

2008 - 2011

SMPN 6

-

-

Tebing Tinggi

-

2005 - 2008

SDN 091292

-

-

Siantar

-

1999 - 2005

KETERAMPILAN KOMPUTER
1. Menguasai Microsoft Office
2. Menguasai Bahasa Pemrograman : C, PHP, MYSQL, CSS dan HTML
3. Kemampuan dalam Bidang Komputer dan Ilmu Robotika

Medan, 24 Januari 2017

(Fadly Tommy)

Universitas Sumatera Utara