DAFTAR PUSTAKA
Endra Pitowarno. 2006. ROBOTIKA Desain, Kontrol, dan Kecedasan Buatan Yogyakarta: Penerbit ANDI Yohanes, H. Dasar – Dasar Elektronika, Ghalia Indonesia, Jakarta, 1983 Rusmadi. Deddy, Aneka Hobby Elektronika 3, CV. Pioner Jaya, Bandung 1992 Rusmadi. Deddy, Aneka Hobby Elektronika 4, Pioner Jaya, Bandung 1992 Rasas, Anggoro. Komponen dan Rangkaian Elektronika, Karya Utama, Jakarta 1987 Didi suryana Drs, dkk. 1997. Keterampilan elektronika. PT. Tiga Serangkai Pustaka Mandiri . Bandung. Candra MD, rangkaian & layout PCB catu daya 5 V dan 12 V , http:// telink. Wordpress.com /2010 /05/ 01 rangkaian dan layout PCB catu daya 5 V dan 12 V/, 4 februari 2015
http://digilib.mercubuana.ac.id/
LAMPIRAN import processing.serial.*; // ambil library serial //-------------------------------------------------definisi variabel2 utk display //variabel tinggi gambar int heightBoxTitle=60; int heightBoxSerial=30; int heightBoxNext=30; int heightBoxOK=30; int heightBoxView=160; int heightBoxButton=40;
//variabel lebar gambar int widthBox=560; int widthBoxView=150; int widthBoxButton=125; int widthBoxNext=50; int widthBoxOK=50;
//variabel posisi sumbu X int xBoxTitle=20; int xBoxSerial=20; int xBoxView1=35; int xBoxView2=225; int xBoxView3=415; int xBoxButton1=20; int xBoxButton2=165;
http://digilib.mercubuana.ac.id/
int xBoxButton3=310; int xBoxButton4=455; int xBoxNext=520; //variabel posisi sumbu Y int yBoxTitle=20; int yBoxSerial=80; int yBoxView=150; int yBoxButton=340; // variabel nilai warna (grayscale) : hitam=0, putih=255 int colorBoxTitle=140; int colorBoxSerial=255; int colorBoxData=100; int colorBoxButton1=200; int colorBoxButton2=200; int colorBoxButton3=200; int colorBoxButton4=200;
//-----------------------------------------------definisi variabel2 status dan tampung data int i,status=0, statusContent=0, statusVar=0; char[] dataVar1= new char[10]; // variabel data 1 char[] dataVar2= new char[10]; // variabel data 2 char[] dataVar3= new char[10]; // variabel data 3
int n,n1,n2,n3;
// variabel2 hitung jumlah port serial (n) dan panjang data serial (n1,n2,n3)
Serial myPort;
// definisi variabel port serial
int val;
// vriabel penerima data karakter serial
http://digilib.mercubuana.ac.id/
void setup() { //------------------------------------------fungsi set up program
if(Serial.list().length==0) status=-1 ;// deteksi jumlah port serial yg aktif, kalau tdk ada, status = -1 else {
//kalau ada, setting serial
String portName = Serial.list()[0];
// ambil nama port serial pertama
myPort = new Serial(this, portName, 9600); }
// set up baudrate
//---------------------------------------------------------set up tampilan
size(600, 400);
//set up ukuran window
background(20);
//set up warna background
noStroke();
//setting gambar2 tanpa border
fill(colorBoxTitle);
// warna gambar kotak judul
rect(xBoxTitle, yBoxTitle, widthBox, heightBoxTitle);// buat gambar kotak, setting posisi X, posisi Y, lebar dan tinggi sesuai variabel fill(colorBoxSerial);
// warna gambar kotak nama serial
rect(xBoxSerial, yBoxSerial, widthBox, heightBoxSerial);//kotak nama serial fill(colorBoxData);
// warna gambar kotak tampilan data
rect(xBoxView1, yBoxView, widthBoxView, heightBoxView);//kotak data 1 rect(xBoxView2, yBoxView, widthBoxView, heightBoxView);//kotak data 2 rect(xBoxView3, yBoxView, widthBoxView, heightBoxView);//kotak data 3
textFont(createFont("Impact",40));
//set up text : ukuran dan jenis font
textAlign(CENTER,CENTER);
http://digilib.mercubuana.ac.id/
fill(255);
//set up warna text
text("SPEDOMETER",300,45); X:300, Y:45
// tampilkan text "SPEDO" di posisi
//-------------------------set up nilai awal variabel statusVar=0; n1=0; n2=0; n3=0; }
//-------------------------------------fungsi program looping-----------------------------------------------------------------void draw() {
if(status!=-1) {//--------------------------------------kalau status bukan -1 (ada port serial aktif) if ( myPort.available() > 0) { // deteksi penerimaan data, val = myPort.read(); i++;
// baca dan taruh di val
// varibel indeks data terus bertambah
if(val=='#') { if(statusVar==1) dataVar1[i]='\0'; proses deteksi satu data selesai, else if(statusVar==2) dataVar2[i]='\0'; masing2 variabel penampung
//kalau data yg diterima = #, maka //
buat karakter penutup"\0" di
else if(statusVar==3) dataVar3[i]='\0'; statusVar=4; } siap ditampilkan
// buat status=4, untuk menandakan data telah
else if(statusVar==1) { n1++; dataVar1[i-1]=(char) val; } // kalau statusVar=1, tampung data serial ke variabel "dataVar1", dan tambahkan nilai n1
http://digilib.mercubuana.ac.id/
else if(statusVar==2) { n2++; dataVar2[i-1]=(char) val; } // kalau statusVar=2, tampung data serial ke variabel "dataVar2", dan tambahkan nilai n2 else if(statusVar==3) { n3++; dataVar3[i-1]=(char) val; } // kalau statusVar=3, tampung data serial ke variabel "dataVar3", dan tambahkan nilai n3
else if(val=='A') { statusVar=1;i=0;n1=0; } else if(val=='B') { statusVar=2;i=0;n2=0; } diterima, buat indeks=0.
// set statusVar sesuai karakter yg
else if(val=='C') { statusVar=3;i=0;n3=0; } } }
if(statusVar==4) {
//kalau data serial siap ditampilkan
statusVar=0; fill(colorBoxData);
//
rect(xBoxView1, yBoxView, widthBoxView, heightBoxView);
//
rect(xBoxView2, yBoxView, widthBoxView, heightBoxView);
//
rect(xBoxView3, yBoxView, widthBoxView, heightBoxView);
//
Data
textFont(createFont("Impact",40)); fill(255);
// //
Tulis
text(dataVar1,0,n1,110,230);
//
Nilai2
text(dataVar2,0,n2,300,230);
//
Data
text(dataVar3,0,n3,490,230);
//
}
fill(colorBoxSerial);
//
http://digilib.mercubuana.ac.id/
Gambar Kotak2
rect(xBoxSerial, yBoxSerial, widthBox, heightBoxSerial); kotak nama serial textFont(createFont("Arial",18));
// Gambar tampilan //
textAlign(CENTER,CENTER);
//
fill(0);
if(status!=-1) { text("SERIAL PORT = "+Serial.list()[n],300,95); status bukan -1, tulis nama port serial aktif
fill(colorBoxButton1);
//kalau
//
rect(xBoxButton1, yBoxButton, widthBoxButton, heightBoxButton); Gambar Kotak2 fill(colorBoxButton2);
//
Tombol
rect(xBoxButton2, yBoxButton, widthBoxButton, heightBoxButton); fill(colorBoxButton3);
//
//
rect(xBoxButton3, yBoxButton, widthBoxButton, heightBoxButton); fill(colorBoxButton4);
//
//
rect(xBoxButton4, yBoxButton, widthBoxButton, heightBoxButton);
fill(0); text("MENU",85,360); text("UP/PLAY",230,360); text("DOWN/PAUSE",370,360); text("CLEAR",520,360); sesuai posisi masing2
//
// tampilkan tulisan2 tombol dan data,
fill(200); text("KECEPATAN",110,170); text("JARAK",300,170);
http://digilib.mercubuana.ac.id/
//
text("WAKTU",490,170); } else text("NO SERIAL PORT DETECTED !!",300,95); tulis warning
fill(colorBoxData);
//
rect(xBoxNext, yBoxSerial, widthBoxNext, heightBoxNext); fill(255); text(">>",550,95);
//kalau status=-1,
// Pembuatan Kotak
// Tombol pilih port serial selanjutnya //
//------------Coding untuk set perubahan warna tombol apabila terlewati kursor mouse-------------------------------------------------------------------if( mouseX>xBoxButton1 && mouseX<(xBoxButton1+widthBoxButton) && mouseY>yBoxButton && mouseY<(yBoxButton+heightBoxButton) ) colorBoxButton1=255; else if( mouseX>xBoxButton2 && mouseX<(xBoxButton2+widthBoxButton) && mouseY>yBoxButton && mouseY<(yBoxButton+heightBoxButton) ) colorBoxButton2=255; else if( mouseX>xBoxButton3 && mouseX<(xBoxButton3+widthBoxButton) && mouseY>yBoxButton && mouseY<(yBoxButton+heightBoxButton) ) colorBoxButton3=255; else if( mouseX>xBoxButton4 && mouseX<(xBoxButton4+widthBoxButton) && mouseY>yBoxButton && mouseY<(yBoxButton+heightBoxButton) ) colorBoxButton4=255; else { colorBoxButton1=200; colorBoxButton2=200; colorBoxButton3=200; colorBoxButton4=200; } } //-----------------------------------------Program looping selesai------------------------------------------------------------------------------------------
http://digilib.mercubuana.ac.id/
void mousePressed() {//-----------------------------------Fungsi Event kalau mouse diklik---------------------------------------------------------------
// Kalau posisi kursor di area box tombol 1, maka tulis ke port serial "1" if( mouseX>xBoxButton1 && mouseX<(xBoxButton1+widthBoxButton) && mouseY>yBoxButton && mouseY<(yBoxButton+heightBoxButton) ) { myPort.write("1"); }
// Kalau posisi kursor di area box tombol 2, maka tulis ke port serial "2" if( mouseX>xBoxButton2 && mouseX<(xBoxButton2+widthBoxButton) && mouseY>yBoxButton && mouseY<(yBoxButton+heightBoxButton) ) { myPort.write("2"); }
// Kalau posisi kursor di area box tombol 3, maka tulis ke port serial "3" if( mouseX>xBoxButton3 && mouseX<(xBoxButton3+widthBoxButton) && mouseY>yBoxButton && mouseY<(yBoxButton+heightBoxButton) ) { myPort.write("3"); }
// Kalau posisi kursor di area box tombol 4, maka tulis ke port serial "4" if( mouseX>xBoxButton4 && mouseX<(xBoxButton4+widthBoxButton) && mouseY>yBoxButton && mouseY<(yBoxButton+heightBoxButton) ) { myPort.write("4"); }
http://digilib.mercubuana.ac.id/
// Kalau posisi kursor di area box tombol ">>" di samping tulisan nama port serial, stop data serial, dan pilih port serial selanjutnya yg aktif if( mouseX>xBoxNext && mouseX<(xBoxNext+widthBoxNext) && mouseY>yBoxSerial && mouseY<(yBoxSerial+heightBoxNext) ) { myPort.stop(); n++; if(n>=Serial.list().length) n=0; String portName = Serial.list()[n]; myPort = new Serial(this, portName, 9600); }
}//--------------------------------------------fungsi event mouse klik selesai-----------------------------------------------------------------------
http://digilib.mercubuana.ac.id/