Anda di halaman 1dari 49

Pengaturan cahaya untuk metode tanam Hidroponik

menggunakan perangkat Android dan Arduino


Novitiyono Wisnu Hadita1,a, Rizki Alandani2,b dan Muhaqiqin3,c
1,2

Teknik Elektro dan 3Ilmu Komputer, Universitas Lampung, Kota Bandar Lampung.
Email: novitiyono.1215031054@students.unila.ac.id, bEmail: rizki.alandani@students.unila.ac.id,
c
Email: muhaqiqin.1217051044@students.unila.ac.id

Abstrak- Hidroponik merupakan suatu sistem tanam tanpa media tanah, salah satu metode menanam hidroponik paling mudah adalah
menggunakan sistem wicks (sumbu). Pada sistem tersebut, metode tanam hidroponik dapat dilakukan di dalam ruangan. Tanaman
hidroponik tetap membutuhkan sumber cahaya untuk melakukan proses fotosintesis. Hanya sedikit dari energi cahaya yang
dipancarkan yang digunakan tanaman untuk fotosintesis karena gelombang cahaya yang ditangkap setiap tanaman berbeda satu
dengan yang lainnya tergantung dari jenis tanaman. Oleh karena itu, perlu dibuat aplikasi alat pengaturan cahaya untuk tanaman
hidroponik sehingga bisa mendapatkan hasil yang optimal. Dengan adanya alat yang dapat mengatur cahaya menggunakan perangkat
Android dan Arduino yang terkoneksi melalui bluetooth, penyesuaian warna dan intensitas cahaya yang dibutuhkan tanaman pada
metode tanam hidroponik dapat membantu mencapai hasil yang optimal.
Keywordshidroponik, wicks, Android, Arduino, RGB LED

I. PENDAHULUAN
A. Latar Belakang
Hidroponik merupakan suatu sistem pertanian masa depan
karena dapat diusahakan di berbagai tempat[1]. Sedikitnya
lahan pertanian, keterbatasan air untuk irigasi, dan musim
yang tidak menentu dapat ditanggulangi dengan sistem
hidroponik. Hidroponik dapat diusahakan sepanjang tahun
tanpa mengenal musim. Pemeliharaan tanaman hidroponik
pun lebih mudah karena tempat budidaya relatif bersih, media
tanam yang steril, tanaman terlindungi dari terpaan hujan,
serangan hama dan penyakit relatif lebih kecil, serta tanaman
lebih sehat dan produktivitas lebih tinggi[2]. Kelebihan lain
metode menanam hidroponik adalah perawatan yang praktis,
pemakaian pupuk lebih hemat, tanaman yang mati lebih
mudah diganti dengan tanaman yang baru, kerja lebih hemat
dan memiliki standar[3].
Pada tanaman, diketahui bahwa energi sinar yang digunakan
tumbuhan untuk fotosintesis hanya 0,5-2% dari jumlah energi
yang tersedia. Energi yang diberikan itu tergantung kepada
kualitas (panjang gelombang), intensitas (banyaknya sinar per
1 cm2 per detik) dan waktu[4]. Setiap tanaman menyerap
cahaya yang berbeda-beda tergantung dari membran grana
yang terdapat pada tumbuhan. Hasil tanaman yang baik
diperoleh melalui perlakuan yang tepat pada tanaman. Salah
satu perlakuan bagi tumbuhan yaitu dengan pengaturan
intensitas cahaya yang didapat karena berhubungan erat
dengan aktivitas fotosintesis tanaman[5]. Pengaturan cahaya
pada tanaman hidroponik dapat dilakukan dengan mengubahubah intensitas dan warna cahaya yang digunakan sehingga
cahaya yang didapat tanaman akan sesuai dengan panjang
gelombang yang dapat diterima tanaman.
Pengaturan cahaya secara otomatis dapat dilakukan
menggunakan perangkat Arduino. Arduino merupakan suatu
papan elektronik yang mengandung mikrokontoller di
dalamnya dan dapat diprogram menggunakan bahasa

Processing[6]. Perangkat Arduino merupakan perangkat keras


open source, perangkat keras open source dapat
dikembangkan dengan penambahan komponen dan secara
umum pengembangnya akan berbeda di seluruh dunia. Serta
software Arduino dapat diunduh, dipakai, dikembangkan,
diubah, bahkan dijual kembali[7]. Jenis Arduino yang
digunakan adalah Arduino Mega 2560, perangkat ini memiliki
54 pin input/output yang mana 15 pin digunakan sebagai
PWM keluaran, 16 masukan analog, 16 MHz osilator kristal,
USB koneksi, power, ICSP, dan tombol reset[8]. Perangkat ini
pun dapat berintegrasi dengan perangkat Android.
Perangkat Android memiliki banyak kelebihan dibandingkan
dengan sistem operasi sejenis. Selain home screen yang
fleksibel, aplikasi yang dapat bekerja secara bersamaan (multi
tasking), sistem operasi Android juga dapat dimodifikasi oleh
pengguna[9]. Pada sisi pengembangan Android, kelebihan
terdapat pada mudahnya pembuatan Aplikasi pada sistem
operasi Android karena menggunakan bahasa tinggat tinggi
Java, dan pengembangan layout menggunakan Extensible
Markup Language (XML)[10].
Kondisi lahan pertanian yang semakin sempit di Indonesia,
serta musim yang tidak menentu menjadikan metode
hidroponik dapat menjadi solusi bagi pertanian Indonesia.
Dengan ditambahkan pengaturan otomatis menggunakan
perangkat Arduino dan Android dapat mempermudah dalam
bercocok tanam metode hidroponik.
B. Rumusan Masalah
Persoalan yang dibahas adalah cara pengaturan cahaya
menggunakan perangkat Android dengan bluetooth sebagai
media untuk komunikasi. Hal ini untuk mempermudah
pengaturan cahaya pada metode tanam hidroponik. Sehingga
cahaya yang digunakan untuk menanam hidroponik dapat
diatur dan diketahui kondisinya. Sistem hidroponik dapat
menjadi solusi bagi pertanian Indonesia karena dapat
dilakukan di lahan yang sempit serta tanaman lebih aman dari
serangan hama dan penyakit. Sehingga metode tanam

hidroponik dengan pengaturan otomatis menggunakan aplikasi


Android dapat memudahkan petani dalam mengatur cahaya
sehingga mendapatkan hasil yang maksimal.

C. Desain Aplikasi

C. Tujuan Penelitian
Tujuan dari penelitian ini adalah terciptanya alat pengaturan
cahaya untuk metode tanam hidroponik menggunakan
perangkat Android dan Arduino sehingga penggunaan alat ini
dapat meningkatkan hasil pertanian.
II. RANCANGAN ALAT
A. Diagram Blok

Gambar 1. Diagram blok alat

Urutan penggunaan alat yang akan dibuat adalah user masuk


kedalam aplikasi lalu memilih mode pengaturan LED (Light
Emitting Diode) menggunakan broadcast atau unit control.
Setelah itu perintah akan dikirimkan melalui bluetooth yang
terdapat pada ponsel kemudian akan diterima oleh bluetooth
module yang tedapat pada Arduino. Sehingga Arduino akan
mengirim perintah kepada LED RGB (Red Green Blue) sesuai
dengan perintah yang dikirimkan oleh user. Data-data yang
terdapat pada Arduino dikirimkan ke aplikasi Android agar
user dapat melihat status pada LED. Terdapat juga pengaturan
waktu (Timer) untuk mengatur pencahayaan pada waktu
tertentu secara otomatis sehingga user tidak perlu merubah
warna cahaya pada setiap waktu.

Gambar 3. Tampilan aplikasi

D. Diagram Alir Program Arduino

B. Desain Alat
Pada alat ini terdapat 3 buah LED RGB untuk mengatur
cahaya pada tanaman hidroponik. Setiap tanaman terdapat
sekat untuk memisahkan antar tanaman agar saat pengaturan
cahaya yang berbeda (unit control) pada LED tidak
mempengaruhi pencahayaan pada bagian yang lain. Metode
tanam pada gambar adalah metode tanam sistem wick (sumbu)
karena metode hidroponik jenis ini paling mudah untuk
diaplikasikan dan paling baik untuk tanaman tunggal[11].

Gambar 2. Desain alat penelitian

Gambar 4. Diagram alir program Arduino

E. Diagram Alir Program Android

III. HASIL SIMULASI


Berikut ini adalah hasil dari simulasi yang dilakukan pada
perangkat Android dan Arduino.
Tabel 2. Uji Coba Umum
No
1
2
3
4
5
6
7

Skenario/Input
Buka aplikasi Android
Menghidupkan bluetooth
Mencari perangkat
Pairing perangkat
Terima data status
Memutuskan perangkat
Keluar aplikasi

Kondisi/Output
Terbuka
Hidup
Bisa
Terhubung
Bisa
Terputus
Bisa

Berhasil

Tabel 3. Uji Fungsional Unit Control


No
1

Perangkat
LED 1

LED 2

LED 3

Skenario/Input
On/Off
Ubah kecerahan
Kombinasi warna
Atur timer
On/Off
Ubah kecerahan
Kombinasi warna
Atur timer
On/Off
Ubah kecerahan
Kombinasi warna
Atur timer

Kondisi/Output
Bisa
Bisa
Bisa
Bisa
Bisa
Bisa
Bisa
Bisa
Bisa
Bisa
Bisa
Bisa

Berhasil

Tabel 4. Uji Fungsional Broadcast


No
1

Perangkat
Semua LED
(LED 1,
LED 2,
LED 3)

Skenario/Input
On/Off
Ubah kecerahan
Kombinasi warna
Atur timer

IV.
Gambar 5. Diagram alir program Android

Perangkat keras yang digunakan adalah sebagai berikut:


1. Android minimum versi 4.1 (Jelly Bean)
2. Arduino Mega 2560
3. Bluetooth Module HC-05
4. Arduino I2C RTC DS1307 AT24C32
5. LED RGB 3 Watt Multicolor
6. Power supply 12V 1.5A
Tabel 1. Spesifikasi Alat
No
1
2
3
4
5
6
7
8
9

Nama
Tegangan Input (AC/DC)
Mikrokontroller
Kecepatan Clock
SRAM
EEPROM
Flash Memory
Perangkat komunikasi
RTC (Real Time Clock)
Output

Keterangan
220V/50Hz / 7-12VDC
ATMega 2560
16 Mhz
8 KB
4 KB
256 KB
Bluetooth Module HC-05
I2C RTC DS1307 AT24C32
3 RGB LED Modules

Kondisi/Output
Bisa
Bisa
Bisa
Bisa

Berhasil

ANALISIS

Pada uji coba pertama adalah melakukan tes aplikasi, yaitu


buka dan tutup aplikasi, dan komunikasi bluetooth dari
aplikasi Android terhadap modul Arduino. Pada uji coba
komunikasi bluetooth, dilakukan beberapa tahapan uji coba
yaitu ketika terdapat perangkat dan tidak ada perangkat, lalu
pairing perangkat, penerimaan data status dari Arduino, dan
memutuskan pairing perangkat. Untuk penerimaan data status
ini nantinya akan diketahui kondisi pada sistem dan dapat
ditampilkan pada aplikasi Android.
Setelah uji coba komunikasi aplikasi, dilanjutkan dengan uji
coba pengaturan LED dengan 2 jenis pengaturan yaitu unit
control dan broadcast. Pada uji coba unit control, pengiriman
perintah dilakukan satu per satu LED dan mengubah
kecerahan pada setiap LED. Kondisi LED mampu berbeda
warna satu dengan yang lainnya pada saat yang bersamaan dan
kecerahannya juga dapat diatur pada setiap LED. Berbeda
dengan unit control, uji coba pada mode broadcast dilakukan
pengaturan warna dan kecerahaan saat yang bersamaan dan
dapat dikerjakan pada saat yang bersamaan oleh semua LED.
Selain itu terdapat fitur timer pada setiap mode, terdapat pada
mode unit control dan broadcast. Timer digunakan untuk

mengatur waktu hidup dan mati serta dapat merubah warna


LED pada waktu tertentu.
V.

KESIMPULAN

Kesimpulan yang didapat adalah aplikasi dimungkinkan


untuk dibuat melihat hasil uji coba dengan keberhasilan penuh
pada setiap bagian uji coba. Sehingga dengan adanya alat ini
dapat memudahkan petani yang menggunakan sistem
bercocok tanam hidroponik dalam pengaturan cahaya
tanaman.
DAFTAR PUSTAKA
[1] Wibowo, Sapto dan Asriyanti, Arum, "Aplikasi Hidroponik NFT pada
Budidaya Pakcoy (Brassica rapa chinensis)," Jurnal Penelitian Pertanian
Terapan, vol. 13, pp. 159-167, 2013.
[2] Tony Hartus, Berkebun Hidroponik Secara Murah, IX ed. Jakarta:
Penerbit Penebar Swadaya, 2008.
[3] Pinus Lingga, Hidroponik: bercocok tanam tanpa tanah. Bandung:
Niaga Swadaya, 1984.
[4] Papib, Handoko dan Yunie, Fajariyanti, "Pengaruh Spektrum Cahaya
Tampak Terhadap Laju Fotosintesis Tanaman Air Hydrilla Verticillata,"
in Seminar Nasional X Pendidikan Biologi, Solo, 2013, pp. 15-147.
[5] Sumeru Ashari, Hortikultura aspek budidaya. Jakarta: Penerbit
Universitas Indonesia, 1995.
[6] Abdul Kadir, Panduan Praktis Mempelajari Aplikasi Mikrokontroller
dan Pemrogramannya menggunakan Arduino. Yogyakarta: Penerbit
Andi, 2013.
[7] Brian Evans, Beginning Arduino Programming. New York: Apress
Publisher, 2011.
[8] Oktariawan I., Martinus, dan Sugiyanto, "Pembuatan Sistem Otomasi
Dispenser Menggunakan Mikrokontroller Arduino Mega 2560," Jurnal
FEMA, vol. 1, pp. 18-24, 2013.
[9] Yuliandi Kusuma, Membedah Kehebatan Android. Jakarta: Grasindo,
2011.
[10] Zigurd Mednieks, Laird Dornin, G. Blake Meike dan Masumi Nakamura,
Programming Android, 2nd ed. California: O'Reilly, 2012.
[11] Douglas Peckenpaugh, Hydroponic Solutions: Volume 1: Hydroponic
Growing Tips. Oregon: New Moon Publishing, 2004.

APPENDIX
A. Program Arduino
#include
#include
#include
#include
const
const
const
const
const
const

<Wire.h>
"RTClib.h"
<LiquidCrystal.h>
<SoftwareSerial.h>// import the serial library

int
int
int
int
int
int

PIN_RS = 34;
PIN_E = 36;
PIN_DB4 = 42;
PIN_DB5 = 44;
PIN_DB6 = 46;
PIN_DB7 = 48;

RTC_DS1307 rtc;
DateTime now;
LiquidCrystal lcd (PIN_RS, PIN_E, PIN_DB4, PIN_DB5, PIN_DB6, PIN_DB7);
SoftwareSerial BTSerial (10, 11); // RX, TX
// pins for the LEDs 1:
const int redPin = 4;
const int greenPin = 3;
const int bluePin = 2;
// pins for the LEDs 2:
const int redPin2 = 7;
const int greenPin2 = 6;
const int bluePin2 = 5;
// pins for the LEDs 3:
const int redPin3 = 12;
const int greenPin3 = 9;
const int bluePin3 = 8;
// pins for the LEDs test:
//const int test = 13;
int x=0;
int str[6]={0,0,0,0,0,0};
//timer variable
int nowHourMinute, start1, start2, start3, end1, end2, end3;
int Red1, Red2, Red3, Green1, Green2, Green3, Blue1, Blue2, Blue3;

void setup() {
// initialize serial:
BTSerial.begin(9600);
lcd.begin(16, 2);
#ifdef AVR
Wire.begin();
#else
Wire1.begin(); // Shield I2C pins connect to alt I2C bus on Arduino Due
#endif
rtc.begin();
if (! rtc.isrunning()) {
BTSerial.println("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}
// make the pins outputs:
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
pinMode(redPin2, OUTPUT);
pinMode(greenPin2, OUTPUT);
pinMode(bluePin2, OUTPUT);
pinMode(redPin3, OUTPUT);
pinMode(greenPin3, OUTPUT);
pinMode(bluePin3, OUTPUT);
//pinMode(test, OUTPUT);
BTSerial.println("Arduino control RGB LEDs Connected OK ( Sent From Arduino
Board )");
lcd.clear();
lcd.print("
Bismillah");
delay(1000);
lcd.clear();
lcd.print("
HydroPhonic");
delay(1000);
lcd.setCursor(6,1);
lcd.print(".");
delay(750);
lcd.setCursor(7,1);
lcd.print(".");
delay(750);
lcd.setCursor(8,1);
lcd.print(".");
delay(400);
}

void loop() {
now = rtc.now();
nowHourMinute = now.hour() * 100 + now.minute();
if (BTSerial.available() > 0){
str[0]=0;str[1]=0;str[2]=0;str[3]=0;str[4]=0;str[5]=0; //return variable to
zero
delay(10);
while (BTSerial.available() > 0){
int byteRead = BTSerial.read();
delay(5);
if (isdigit(byteRead)){
str[x]=(str[x]*10)+(byteRead-48);
}
else if (byteRead==':'){
//break;
x++;
}
else if (byteRead==';'){
//str[0] = constrain(str[0], 0, 255);
//str[1] = constrain(str[1], 0, 255);
//str[2] = constrain(str[2], 0, 255);
x=0;
if (str[4]==0 && str[5]==0){
LEDCase();
start1=0;start2=0;start3=0;end1=0;end2=0;end3=0;
}
else {
if (str[4]>0 && str[5]==0){
str[5]=2400;
}
timecase();
}
BTSerial.println("executed");
}
}
}
timer();
delay(10);
}
else {
fourthValue = myString.substring(thirdCommaIndex+1);
LEDcase();
}
}

void LED1(){
// fade the red, green, and blue legs of the LED:
analogWrite(redPin, Red1);
analogWrite(greenPin, Green1);
analogWrite(bluePin, Blue1);
}
void LED2(){
// fade the red, green, and blue legs of the LED 2:
analogWrite(redPin2, Red2);
analogWrite(greenPin2, Green2);
analogWrite(bluePin2, Blue2);
}
void LED3(){
// fade the red, green, and blue legs of the LED 3:
analogWrite(redPin3, Red3);
analogWrite(greenPin3, Green3);
analogWrite(bluePin3, Blue3);
}
void LEDCase(){
if (str[3] == 11){
Red1 = str[0]; Green1
LED1();
}
else if (str[3] == 22){
Red2 = str[0]; Green2
LED2();
}
else if (str[3] == 33){
Red3 = str[0]; Green3
LED3();
}
else if (str[3] == 99){
Red1 = str[0]; Green1
Red2 = str[0]; Green2
Red3 = str[0]; Green3
LED1();LED2();LED3();
}
}

= str[1]; Blue1 = str[2];

= str[1]; Blue2 = str[2];

= str[1]; Blue3 = str[2];

= str[1]; Blue1 = str[2];


= str[1]; Blue2 = str[2];
= str[1]; Blue3 = str[2];

void timer(){
lcd.clear();
if (start1>0 || end1>0){
if (nowHourMinute >= start1 && nowHourMinute < end1){
LED1();
lcd.print(end1);
}
else {
analogWrite(redPin, 0);
analogWrite(greenPin, 0);
analogWrite(bluePin, 0);
lcd.print(start1);
}
}
delay(10);
if (start2>0 || end2>0){
if (nowHourMinute >= start2 && nowHourMinute < end2){
LED2();
lcd.setCursor(0,1);lcd.print(end2);
}
else {
analogWrite(redPin2, 0);
analogWrite(greenPin2, 0);
analogWrite(bluePin2, 0);
lcd.setCursor(0,1);lcd.print(start2);
}
}
delay(10);
if (start3>0 || end3>0){
if (nowHourMinute >= start3 && nowHourMinute < end3){
LED3();
lcd.setCursor(11,0);lcd.print(end3);
}
else {
analogWrite(redPin3, 0);
analogWrite(greenPin3, 0);
analogWrite(bluePin3, 0);
lcd.setCursor(11,0);lcd.print(start3);
}
}
delay(10);
lcd.setCursor(11,1);lcd.print(nowHourMinute);
delay(100);
}

void timecase(){
//transfer variable for
if (str[3] == 11){
Red1 = str[0]; Green1
start1=str[4];
end1=str[5];
}
else if (str[3] == 22){
Red2 = str[0]; Green2
start2=str[4];
end2=str[5];
}
else if (str[3] == 33){
Red3 = str[0]; Green3
start3=str[4];
end3=str[5];
}
else if (str[3] == 99){
Red1 = str[0]; Green1
Red2 = str[0]; Green2
Red3 = str[0]; Green3
start1=str[4];
end1=str[5];
start2=str[4];
end2=str[5];
start3=str[4];
end3=str[5];
}
}

timer
= str[1]; Blue1 = str[2];

= str[1]; Blue2 = str[2];

= str[1]; Blue3 = str[2];

= str[1]; Blue1 = str[2];


= str[1]; Blue2 = str[2];
= str[1]; Blue3 = str[2];

B. Program Android

package com.qiqi.hydrophonicbt;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.UUID;
import android.support.v7.app.ActionBarActivity;
import android.annotation.TargetApi;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.PopupMenu;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.Switch;
import android.widget.Toast;
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public class MainActivity extends ActionBarActivity implements OnItemSelectedListener {
String[] kategori= {"Tanaman Hijau","Tanaman Merah","Tanaman
Ungu","Custom"};
String[][] tHijau={{"Bayam Hijau","Kangkung","Cabai Hijau"},
{"255:0:0:0730:1730","255:0:0:0830:1630","255:0:0:0630:1630"}
};
String[][] tMerah={{"Cabai Merah","Tomat","Bayam Merah"},
{"0:255:255:0730:1730","0:255:255:0830:1630","0:255:255:0630:1630"}
};
String[][] tUngu={{"Terong","Anggur","Kol Ungu"},

{"0:255:0:0730:1730","0:255:0:0830:1630","0:255:0:0630:1630"}
};
RadioGroup rg;
Spinner spinK, spinJ;
RadioButton all;
DBAdapter DBA;
//Member Fields
private BluetoothAdapter btAdapter = null;
private BluetoothSocket btSocket = null;
private OutputStream outStream = null;
// UUID service - This is the type of Bluetooth device that the BT module is
// It is very likely yours will be the same, if not google UUID for your manufacturer
private static final UUID MY_UUID = UUID.fromString("00001101-0000-10008000-00805F9B34FB");
// MAC-address of Bluetooth module
public String newAddress2 = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
spinK = (Spinner) findViewById(R.id.spinK);
ArrayAdapter<String> adapterK= new ArrayAdapter<String>(
this, android.R.layout.simple_spinner_item, kategori);
spinK.setAdapter(adapterK);
spinK.setOnItemSelectedListener(this);
spinJ = (Spinner) findViewById(R.id.spinJ);
ArrayAdapter<String> adapterJ= new ArrayAdapter<String>(
this, android.R.layout.simple_spinner_item, tHijau[0]);
spinJ.setAdapter(adapterJ);
spinJ.setOnItemSelectedListener(this);
btAdapter = BluetoothAdapter.getDefaultAdapter();
checkBTState();
}

@Override
public void onResume() {

super.onResume();
// connection methods are best here in case program goes into the background etc
Log.i("State : ", "On Resume");
Intent intent = getIntent();
newAddress2 = intent.getStringExtra("DEVICE_ADDRESS");
if(newAddress2.equals(null)){
SharedPreferences sharedPref =
MainActivity.this.getPreferences(Context.MODE_PRIVATE);
newAddress2 = sharedPref.getString("BT_ADDRESS", newAddress2);
}
BluetoothDevice device = btAdapter.getRemoteDevice(newAddress2);
try {
btSocket = device.createRfcommSocketToServiceRecord(MY_UUID);
} catch (IOException e1) {
Toast.makeText(getBaseContext(), "ERROR - Could not create Bluetooth
socket", Toast.LENGTH_SHORT).show();
}
try {
btSocket.connect();
} catch (IOException e) {
try {
btSocket.close();
//If IO exception occurs attempt to close socket
} catch (IOException e2) {
Toast.makeText(getBaseContext(), "ERROR - Could not close Bluetooth
socket", Toast.LENGTH_SHORT).show();
}
}
try {
outStream = btSocket.getOutputStream();
} catch (IOException e) {
Toast.makeText(getBaseContext(), "ERROR - Could not create bluetooth
outstream", Toast.LENGTH_SHORT).show();
}
}

@Override
public void onPause() {
super.onPause();
Intent intent = getIntent();
newAddress2 = intent.getStringExtra("DEVICE_ADDRESS");
SharedPreferences sharedPref =
MainActivity.this.getPreferences(Context.MODE_PRIVATE);

SharedPreferences.Editor editor = sharedPref.edit();


editor.putString("BT_ADDRESS", newAddress2);
editor.commit();
//Pausing can be the end of an app if the device kills it or the user doesn't open it
again
//close all connections so resources are not wasted
Log.i("State : ", "On Pause");
//Close BT socket to device
try {
btSocket.close();
} catch (IOException e2) {
Toast.makeText(getBaseContext(), "ERROR - Failed to close Bluetooth socket",
Toast.LENGTH_SHORT).show();
}
}

private BluetoothSocket createBluetoothSocket(BluetoothDevice device) throws


IOException {
return device.createRfcommSocketToServiceRecord(MY_UUID);
}
private void checkBTState() {
// Check device has Bluetooth and that it is turned on
if(btAdapter==null) {
Toast.makeText(getBaseContext(), "ERROR - Device does not support
bluetooth", Toast.LENGTH_SHORT).show();
finish();
} else {
if (btAdapter.isEnabled()) {
} else {
//Prompt user to turn on Bluetooth
Intent enableBtIntent = new
Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, 1);
}
}
}

//
//

public void showMenu(View v, String nama) {


PopupMenu popup = new PopupMenu(this, v);
final String Code = code;
final String Nama = nama;
final String Time = time;
// This activity implements OnMenuItemClickListener

popup.inflate(R.menu.context_menu);
popup.setOnMenuItemClickListener(new
PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
switch (menuItem.getItemId()) {
case R.id.edit:
//
Edit(Nama, Code, Time);
return true;
case R.id.delete:
//s
Delete(Nama);
return true;
}
return false;
}
});
popup.show();
}

public void options(View v){


spinK = (Spinner) findViewById(R.id.spinK);
String nama1 =
spinJ.getSelectedItem().toString();
if(nama1.equals("Custom")){
spinJ = (Spinner) findViewById(R.id.spinJ);
String nama = spinJ.getSelectedItem().toString();
/*

String Code="";
String Time="";
try{
DBAdapter db = new DBAdapter(this);
db.open();

Cursor d = db.getCode(nama);
if(d.moveToFirst()){
do{
Code = d.getString(2);
Time = d.getString(3);
}while (d.moveToNext());
}
db.close();
//
Toast.makeText(this, Time, Toast.LENGTH_LONG).show();
*/
showMenu(v, nama);
//
}
//
catch(Exception e){
//
Toast.makeText(this, "Gagal",
Toast.LENGTH_LONG).show();
//
}

}
}
public void Delete(String nama){
try{
DBAdapter db = new DBAdapter(this);
db.open();
db.deleteList(nama);
db.close();
Toast.makeText(this, "Data berhasil dimasukkan",
Toast.LENGTH_LONG).show();
Intent intent = getIntent();
Intent refresh = new Intent(this, MainActivity.class);
startActivity(refresh);
this.finish();
}catch(Exception e){
Toast.makeText(this, e.getMessage(),
2000).show();
}
}

public void Edit(String nama, String code, String time){


//
Toast.makeText(this, nama+"\n"+code+"\n"+time,
Toast.LENGTH_LONG).show();
Intent intent = getIntent();
newAddress2 = intent.getStringExtra("DEVICE_ADDRESS");
Intent i = new Intent(this, EditProfile.class);
i.putExtra("Nama", nama);
i.putExtra("Code", code);
i.putExtra("Time", time);
i.putExtra("ADDRESS", newAddress2);
startActivity(i);
}

//

private void sendData(String message) {


Toast.makeText(this, message, 1000).show();
byte[] msgBuffer = message.getBytes();
try {
//attempt to place data on the outstream to the BT device

outStream.write(msgBuffer);
Toast.makeText(this, "Sending Succes", 1000).show();
try {
Thread.sleep(50);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (IOException e) {
//if the sending fails this is most likely because device is no longer there
Toast.makeText(getBaseContext(), "ERROR - Device not found",
Toast.LENGTH_SHORT).show();
finish();
}

//

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onItemSelected(AdapterView<?> list, View v, int position,
long id) {
// TODO Auto-generated method stub
switch(list.getId()){
case R.id.spinK:
String namaK = (String) list.getItemAtPosition(position);
Jenis(namaK);
break;
case R.id.spinJ:
String namaJ = list.getItemAtPosition(position).toString();
Add(namaJ);

break;
}
}
public void Add(String add){
if(add.equals("Add")){
Intent intent = getIntent();
newAddress2 = intent.getStringExtra("DEVICE_ADDRESS");
Intent i = new Intent(this, Profile.class);
i.putExtra("ADDRESS", newAddress2);
startActivity(i);
}
}
public void Jenis(String jenis){
if(jenis.equals("Tanaman Hijau")){
spinJ = (Spinner) findViewById(R.id.spinJ);
ArrayAdapter<String> adapterJ= new ArrayAdapter<String>(
this, android.R.layout.simple_spinner_item, tHijau[0]);
spinJ.setAdapter(adapterJ);
}
if(jenis.equals("Tanaman Merah")){
spinJ = (Spinner) findViewById(R.id.spinJ);
ArrayAdapter<String> adapterJ= new ArrayAdapter<String>(
this, android.R.layout.simple_spinner_item, tMerah[0]);
spinJ.setAdapter(adapterJ);
}
if(jenis.equals("Tanaman Ungu")){
spinJ = (Spinner) findViewById(R.id.spinJ);
ArrayAdapter<String> adapterJ= new ArrayAdapter<String>(
this, android.R.layout.simple_spinner_item, tUngu[0]);
spinJ.setAdapter(adapterJ);
}
if(jenis.equals("Custom")){
DBA = new DBAdapter(this);
DBA.open();
spinJ = (Spinner) findViewById(R.id.spinJ);
List values = DBA.getAllPelanggan();
values.add("Add");
// Use the SimpleCursorAdapter to show the
// elements in a ListView

ArrayAdapter adapterJ = new ArrayAdapter(this,


android.R.layout.simple_spinner_item, values);
spinJ.setAdapter(adapterJ);
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
public void Reset(View v){
String led = "99";
rg = (RadioGroup) findViewById(R.id.radioGroup1);
int abc = rg.getCheckedRadioButtonId();
switch(abc){
case R.id.rbLED1:
led = "11";
break;
case R.id.rbLED2:
led = "22";
break;
case R.id.rbLED3:
led = "33";
break;
case R.id.rbAll:
led = "99";
break;
}
sendData("0:0:0:"+led+";");
}
public void Submit(View v){
String led = "99";
rg = (RadioGroup) findViewById(R.id.radioGroup1);
int abc = rg.getCheckedRadioButtonId();
Switch sw = (Switch) findViewById(R.id.switch1);
switch(abc){
case R.id.rbLED1:
led = "11";
break;
case R.id.rbLED2:
led = "22";
break;
case R.id.rbLED3:
led = "33";

break;
case R.id.rbAll:
led = "99";
break;
}
spinJ = (Spinner) findViewById(R.id.spinJ);
int index = spinJ.getSelectedItemPosition();
String JenTum = spinJ.getSelectedItem().toString();
spinK = (Spinner) findViewById(R.id.spinK);
String Jenis = spinK.getSelectedItem().toString();
String ColorCode = "";
if(Jenis.equals("Tanaman Hijau")){
ColorCode = tHijau[1][index];
}
if(Jenis.equals("Tanaman Merah")){
ColorCode = tMerah[1][index];
}
if(Jenis.equals("Tanaman Ungu")){
ColorCode = tUngu[1][index];
}
if(Jenis.equals("Custom")){
String Code="";
String Time="";
if(!JenTum.equals("Add")){
try{
DBAdapter db = new DBAdapter(this);
db.open();
Cursor d = db.getCode(JenTum);
if(d.moveToFirst()){
do{
Code = d.getString(2);
Time = d.getString(3);
}while (d.moveToNext());
}
db.close();
//
Toast.makeText(this, Time, Toast.LENGTH_LONG).show();
ColorCode = Code+":"+Time;
}
catch(Exception e){
Toast.makeText(this, "Gagal",
Toast.LENGTH_LONG).show();
}
}
}

try{
PisahKata p = new PisahKata();
p.Pisah(ColorCode);

//
//
//
//

//

String code = ""+p.v.get(0)+":"+p.v.get(1)+":"+p.v.get(2);


String time = ""+p.v.get(3)+":"+p.v.get(4);
Toast.makeText(this, JenTum, 1000).show();
Toast.makeText(this, ColorCode, 1000).show();
Toast.makeText(this, code+":"+led+":"+time+";", 2000).show();
if(sw.isChecked()){
sendData(code+":"+led+":"+time+";");
Toast.makeText(this, code+":"+led+":"+time+";", 2000).show();
}
if(!sw.isChecked()){
sendData(code+":"+led+";");
Toast.makeText(this, code+":"+led+";", 2000).show();
}
}catch(Exception e){
Toast.makeText(this, e.getMessage(), 1000).show();
}
}

package com.qiqi.hydrophonicbt;
import java.io.IOException;
import java.io.OutputStream;
import java.util.UUID;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;

import android.widget.Spinner;
import android.widget.Toast;
public class Profile extends Activity implements OnSeekBarChangeListener {
String [] jam = {"00","01","02","03","04","05","06","07","08","09"
,"10","11","12","13","14","15","16","17","18","19","20","21","22","23"};
String [] menit = {"00","01","02","03","04","05","06","07","08","09"
,"10","11","12","13","14","15","16","17","18","19","20","21","22","23"
,"24","25","26","27","28","29","30","31","32","33","34","35","36","37"
,"38","39","40","41","42","43","44","45","46","47","48","49","50","51"
,"52","53","54","55","56","57","58","59"};
EditText edNama;
EditText edR, edG, edB;
Spinner jamMulai, menitMulai, jamSelesai, menitSelesai;
SeekBar sRedP, sGreenP, sBlueP;
//Member Fields
private BluetoothAdapter btAdapter = null;
private BluetoothSocket btSocket = null;
private OutputStream outStream = null;
// UUID service - This is the type of Bluetooth device that the BT module is
// It is very likely yours will be the same, if not google UUID for your manufacturer
private static final UUID MY_UUID = UUID.fromString("00001101-0000-10008000-00805F9B34FB");
// MAC-address of Bluetooth module
public String newAddress = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.profile);
edNama = (EditText) findViewById(R.id.edNama);
edR = (EditText) findViewById(R.id.edR);
edG = (EditText) findViewById(R.id.edG);
edB = (EditText) findViewById(R.id.edB);
jamMulai = (Spinner) findViewById(R.id.JamMulai);
ArrayAdapter<String> jm= new ArrayAdapter<String>(
this, android.R.layout.simple_spinner_item, jam);

jamMulai.setAdapter(jm);
menitMulai = (Spinner) findViewById(R.id.MenitMulai);
ArrayAdapter<String> mm= new ArrayAdapter<String>(
this, android.R.layout.simple_spinner_item, menit);
menitMulai.setAdapter(mm);
jamSelesai = (Spinner) findViewById(R.id.JamSelesai);
ArrayAdapter<String> js= new ArrayAdapter<String>(
this, android.R.layout.simple_spinner_item, jam);
jamSelesai.setAdapter(js);
menitSelesai = (Spinner) findViewById(R.id.MenitSelesai);
ArrayAdapter<String> ms= new ArrayAdapter<String>(
this, android.R.layout.simple_spinner_item, menit);
menitSelesai.setAdapter(ms);
sRedP=(SeekBar) findViewById(R.id.seekRp);
sGreenP=(SeekBar) findViewById(R.id.seekGp);
sBlueP=(SeekBar) findViewById(R.id.seekBp);
sRedP.setOnSeekBarChangeListener(this);
sGreenP.setOnSeekBarChangeListener(this);
sBlueP.setOnSeekBarChangeListener(this);
//getting the bluetooth adapter value and calling checkBTstate function
btAdapter = BluetoothAdapter.getDefaultAdapter();
checkBTState();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.save, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.saveMenu) {
Save();
Intent intent = getIntent();
newAddress = intent.getStringExtra("ADDRESS");

Intent i = new Intent(this, MainActivity.class);


i.putExtra("DEVICE_ADDRESS", newAddress);
startActivity(i);
return true;
}
if (id == R.id.cancelMenu) {
Intent intent = getIntent();
newAddress = intent.getStringExtra("ADDRESS");
Intent i = new Intent(this, MainActivity.class);
i.putExtra("DEVICE_ADDRESS", newAddress);
startActivity(i);
return true;
}
return super.onOptionsItemSelected(item);
}
public void Save(){
String nama, red, green, blue, code;
if((!edR.getText().equals(null))&&
(!edG.getText().equals(null))&&
(!edB.getText().equals(null))
){
jamMulai = (Spinner) findViewById(R.id.JamMulai);
menitMulai = (Spinner) findViewById(R.id.MenitMulai);
jamSelesai = (Spinner) findViewById(R.id.JamSelesai);
menitSelesai = (Spinner) findViewById(R.id.MenitSelesai);
String jMulai = jamMulai.getSelectedItem().toString();
String mMulai = menitMulai.getSelectedItem().toString();
String jSelesai = jamSelesai.getSelectedItem().toString();
String mSelesai = menitSelesai.getSelectedItem().toString();
String waktu = jMulai+""+mMulai+":"+jSelesai+""+mSelesai;

//
//

nama = edNama.getText().toString();
red = edR.getText().toString();
green = edG.getText().toString();
blue = edB.getText().toString();
code = red+":"+green+":"+blue;
Toast.makeText(this, "Nama : "+nama
+"\nCode : "+red+":"+green+":"+blue, 1000).show();
try{
DBAdapter db = new DBAdapter(this);
db.open();
long id;

id = db.insertList(nama,code,waktu);
db.close();
Toast.makeText(this, "Data berhasil
dimasukkan",
Toast.LENGTH_LONG).show();
}catch(Exception e){
Toast.makeText(this, "Data tidak berhasil
dimasukkan" +
"\nMungkin Nama Profile Sudah
Terpakai",
2000).show();
}
}
}

@Override
public void onResume() {
super.onResume();
// connection methods are best here in case program goes into the background etc
Log.i("State : ", "On Resume");
Intent intent = getIntent();
newAddress = intent.getStringExtra("ADDRESS");
BluetoothDevice device = btAdapter.getRemoteDevice(newAddress);
try {
btSocket = device.createRfcommSocketToServiceRecord(MY_UUID);
} catch (IOException e1) {
Toast.makeText(getBaseContext(), "ERROR - Could not create Bluetooth
socket", Toast.LENGTH_SHORT).show();
}
try {
btSocket.connect();
} catch (IOException e) {
try {
btSocket.close();
//If IO exception occurs attempt to close socket
} catch (IOException e2) {
Toast.makeText(getBaseContext(), "ERROR - Could not close Bluetooth
socket", Toast.LENGTH_SHORT).show();
}
}
try {

outStream = btSocket.getOutputStream();
} catch (IOException e) {
Toast.makeText(getBaseContext(), "ERROR - Could not create bluetooth
outstream", Toast.LENGTH_SHORT).show();
}
}

@Override
public void onPause() {
super.onPause();
//Pausing can be the end of an app if the device kills it or the user doesn't open it
again
//close all connections so resources are not wasted
Log.i("State : ", "On Pause");
//Close BT socket to device
try {
btSocket.close();
} catch (IOException e2) {
Toast.makeText(getBaseContext(), "ERROR - Failed to close Bluetooth socket",
Toast.LENGTH_SHORT).show();
}
}

private BluetoothSocket createBluetoothSocket(BluetoothDevice device) throws


IOException {
return device.createRfcommSocketToServiceRecord(MY_UUID);
}
private void checkBTState() {
// Check device has Bluetooth and that it is turned on
if(btAdapter==null) {
Toast.makeText(getBaseContext(), "ERROR - Device does not support
bluetooth", Toast.LENGTH_SHORT).show();
finish();
} else {
if (btAdapter.isEnabled()) {
} else {
//Prompt user to turn on Bluetooth
Intent enableBtIntent = new
Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, 1);
}
}
}

//

private void sendData(String message) {


Toast.makeText(this, message, 1000).show();
byte[] msgBuffer = message.getBytes();
try {
//attempt to place data on the outstream to the BT device
outStream.write(msgBuffer);
Toast.makeText(this, "Sending Succes", 1000).show();
try {
Thread.sleep(50);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (IOException e) {
//if the sending fails this is most likely because device is no longer there
Toast.makeText(getBaseContext(), "ERROR - Device not found",
Toast.LENGTH_SHORT).show();
finish();
}

//

@Override
public void onProgressChanged(SeekBar seekbar, int progress,
boolean fromUser) {
// TODO Auto-generated method stub
edR = (EditText) findViewById(R.id.edR);
edG = (EditText) findViewById(R.id.edG);
edB = (EditText) findViewById(R.id.edB);
if(seekbar == sRedP||seekbar == sGreenP||seekbar == sBlueP){
edR.setText(""+sRedP.getProgress());
edG.setText(""+sGreenP.getProgress());
edB.setText(""+sBlueP.getProgress());
try{
sendData(sRedP.getProgress()+":"+sGreenP.getProgress()+":"
+sBlueP.getProgress()+":99;");
}catch(Exception e){
Toast.makeText(getBaseContext(), e.getMessage(),
Toast.LENGTH_SHORT).show();
}

}
}
@Override
public void onStartTrackingTouch(SeekBar arg0) {
// TODO Auto-generated method stub
}
@Override
public void onStopTrackingTouch(SeekBar arg0) {
// TODO Auto-generated method stub
}
}
package com.qiqi.hydrophonicbt;
import java.util.Set;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
public class DeviceListActivity extends Activity {
// textview for connection status
TextView textConnectionStatus;
ListView pairedListView;
//An EXTRA to take the device MAC to the next activity
public static String EXTRA_DEVICE_ADDRESS;
// Member fields

private BluetoothAdapter mBtAdapter;


private ArrayAdapter<String> mPairedDevicesArrayAdapter;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.device_list);
textConnectionStatus = (TextView) findViewById(R.id.connecting);
textConnectionStatus.setTextSize(40);
// Initialize array adapter for paired devices
mPairedDevicesArrayAdapter = new ArrayAdapter<String>(this,
R.layout.device_name);
// Find and set up the ListView for paired devices
pairedListView = (ListView) findViewById(R.id.paired_devices);
pairedListView.setOnItemClickListener(mDeviceClickListener);
pairedListView.setAdapter(mPairedDevicesArrayAdapter);
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
registerReceiver(mReceiver, filter); // Don't forget to unregister during onDestroy
Button scan = (Button) findViewById(R.id.btScan);
scan.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
// Register the BroadcastReceiver
mBtAdapter.startDiscovery();
}
});
}
@Override
public void onResume()
{
super.onResume();
//It is best to check BT status at onResume in case something has changed while app was
paused etc
checkBTState();
mPairedDevicesArrayAdapter.clear();// clears the array so items aren't duplicated when

resuming from onPause


textConnectionStatus.setText(" "); //makes the textview blank
// Get the local Bluetooth adapter
mBtAdapter = BluetoothAdapter.getDefaultAdapter();
// Get a set of currently paired devices and append to pairedDevices list
Set<BluetoothDevice> pairedDevices = mBtAdapter.getBondedDevices();
// Add previously paired devices to the array
if (pairedDevices.size() > 0) {
findViewById(R.id.title_paired_devices).setVisibility(View.VISIBLE);//make title
viewable
for (BluetoothDevice device : pairedDevices) {
mPairedDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
}
} else {
mPairedDevicesArrayAdapter.add("no devices paired");
}
}
//method to check if the device has Bluetooth and if it is on.
//Prompts the user to turn it on if it is off
private void checkBTState()
{
// Check device has Bluetooth and that it is turned on
mBtAdapter=BluetoothAdapter.getDefaultAdapter(); // CHECK THIS OUT THAT
IT WORKS!!!
if(mBtAdapter==null) {
Toast.makeText(getBaseContext(), "Device does not support Bluetooth",
Toast.LENGTH_SHORT).show();
finish();
} else {
if (!mBtAdapter.isEnabled()) {
//Prompt user to turn on Bluetooth
Intent enableBtIntent = new
Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, 1);
}
}
}
// Set up on-click listener for the listview
private OnItemClickListener mDeviceClickListener = new OnItemClickListener()
{
public void onItemClick(AdapterView<?> av, View v, int arg2, long arg3)
{

textConnectionStatus.setText("Connecting...");
// Get the device MAC address, which is the last 17 chars in the View
String info = ((TextView) v).getText().toString();
String address = info.substring(info.length() - 17);
// Make an intent to start next activity while taking an extra which is the MAC
address.
Intent i = new Intent(DeviceListActivity.this, MainActivity.class);
i.putExtra("DEVICE_ADDRESS", address);
startActivity(i);
}
};
// Create a BroadcastReceiver for ACTION_FOUND
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Toast.makeText(context, "Start Discovery", 2000).show();
// When discovery finds a device
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
// Get the BluetoothDevice object from the Intent
BluetoothDevice device =
intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
// Add the name and address to an array adapter to show in a ListView
mPairedDevicesArrayAdapter.add("P : "+device.getName() + "\n" +
device.getAddress());
}
}
};
@Override
public void onDestroy(){
super.onDestroy();
unregisterReceiver(mReceiver);
}
}

package com.qiqi.hydrophonicbt;
import java.io.IOException;
import java.io.OutputStream;
import java.util.UUID;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.Spinner;
import android.widget.Toast;
public class EditProfile extends Activity implements OnSeekBarChangeListener {
String [] jam = {"00","01","02","03","04","05","06","07","08","09"
,"10","11","12","13","14","15","16","17","18","19","20","21","22","23"};
String [] menit = {"00","01","02","03","04","05","06","07","08","09"
,"10","11","12","13","14","15","16","17","18","19","20","21","22","23"
,"24","25","26","27","28","29","30","31","32","33","34","35","36","37"
,"38","39","40","41","42","43","44","45","46","47","48","49","50","51"
,"52","53","54","55","56","57","58","59"};
EditText edNama;
EditText edR, edG, edB;
Spinner jamMulai, menitMulai, jamSelesai, menitSelesai;
SeekBar sRedP, sGreenP, sBlueP;
//Member Fields
private BluetoothAdapter btAdapter = null;
private BluetoothSocket btSocket = null;
private OutputStream outStream = null;
// UUID service - This is the type of Bluetooth device that the BT module is
// It is very likely yours will be the same, if not google UUID for your manufacturer
private static final UUID MY_UUID = UUID.fromString("00001101-0000-10008000-00805F9B34FB");
// MAC-address of Bluetooth module
public String newAddress = null;
@Override

protected void onCreate(Bundle savedInstanceState) {


super.onCreate(savedInstanceState);
setContentView(R.layout.profile);
edNama = (EditText) findViewById(R.id.edNama);
edR = (EditText) findViewById(R.id.edR);
edG = (EditText) findViewById(R.id.edG);
edB = (EditText) findViewById(R.id.edB);
jamMulai = (Spinner) findViewById(R.id.JamMulai);
ArrayAdapter<String> jm= new ArrayAdapter<String>(
this, android.R.layout.simple_spinner_item, jam);
jamMulai.setAdapter(jm);
menitMulai = (Spinner) findViewById(R.id.MenitMulai);
ArrayAdapter<String> mm= new ArrayAdapter<String>(
this, android.R.layout.simple_spinner_item, menit);
menitMulai.setAdapter(mm);
jamSelesai = (Spinner) findViewById(R.id.JamSelesai);
ArrayAdapter<String> js= new ArrayAdapter<String>(
this, android.R.layout.simple_spinner_item, jam);
jamSelesai.setAdapter(js);
menitSelesai = (Spinner) findViewById(R.id.MenitSelesai);
ArrayAdapter<String> ms= new ArrayAdapter<String>(
this, android.R.layout.simple_spinner_item, menit);
menitSelesai.setAdapter(ms);
sRedP=(SeekBar) findViewById(R.id.seekRp);
sGreenP=(SeekBar) findViewById(R.id.seekGp);
sBlueP=(SeekBar) findViewById(R.id.seekBp);
Intent intent = getIntent();
String Enama = intent.getStringExtra("Nama");
String Ecode = intent.getStringExtra("Code");
PisahKata p2 = new PisahKata();
p2.Pisah(Ecode);
String R = ""+p2.v.get(0);
String G = ""+p2.v.get(1);
String B = ""+p2.v.get(2);
edNama.setText(Enama);
edR.setText(R);
edG.setText(G);
edB.setText(B);

sRedP.setOnSeekBarChangeListener(this);
sGreenP.setOnSeekBarChangeListener(this);
sBlueP.setOnSeekBarChangeListener(this);
//getting the bluetooth adapter value and calling checkBTstate function
btAdapter = BluetoothAdapter.getDefaultAdapter();
checkBTState();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.save, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.saveMenu) {
Save();
Intent intent = getIntent();
newAddress = intent.getStringExtra("ADDRESS");
Intent i = new Intent(this, MainActivity.class);
i.putExtra("DEVICE_ADDRESS", newAddress);
startActivity(i);
return true;
}
if (id == R.id.cancelMenu) {
Intent intent = getIntent();
newAddress = intent.getStringExtra("ADDRESS");
Intent i = new Intent(this, MainActivity.class);
i.putExtra("DEVICE_ADDRESS", newAddress);
startActivity(i);
return true;
}
return super.onOptionsItemSelected(item);
}
public void Save(){
String nama, red, green, blue, code;
if((!edR.getText().equals(null))&&
(!edG.getText().equals(null))&&

(!edB.getText().equals(null))
){
jamMulai = (Spinner) findViewById(R.id.JamMulai);
menitMulai = (Spinner) findViewById(R.id.MenitMulai);
jamSelesai = (Spinner) findViewById(R.id.JamSelesai);
menitSelesai = (Spinner) findViewById(R.id.MenitSelesai);
String jMulai = jamMulai.getSelectedItem().toString();
String mMulai = menitMulai.getSelectedItem().toString();
String jSelesai = jamSelesai.getSelectedItem().toString();
String mSelesai = menitSelesai.getSelectedItem().toString();
String waktu = jMulai+""+mMulai+":"+jSelesai+""+mSelesai;
Intent intent = getIntent();
String Enama = intent.getStringExtra("Nama");
nama = edNama.getText().toString();
red = edR.getText().toString();
green = edG.getText().toString();
blue = edB.getText().toString();
code = red+":"+green+":"+blue;
Toast.makeText(this, "Nama : "+nama
+"\nCode : "+red+":"+green+":"+blue, 1000).show();
try{

//
//

DBAdapter db = new DBAdapter(this);


db.open();
db.updateList(Enama,nama,code,waktu);
db.close();
Toast.makeText(this, "Data berhasil
dimasukkan",
Toast.LENGTH_LONG).show();
}catch(Exception e){
Toast.makeText(this, "Data tidak berhasil
dimasukkan" +
"\nMungkin Nama Profile Sudah
Terpakai",
2000).show();
}
}
}

@Override
public void onResume() {
super.onResume();
// connection methods are best here in case program goes into the background etc
Log.i("State : ", "On Resume");
Intent intent = getIntent();
newAddress = intent.getStringExtra("ADDRESS");
BluetoothDevice device = btAdapter.getRemoteDevice(newAddress);
try {
btSocket = device.createRfcommSocketToServiceRecord(MY_UUID);
} catch (IOException e1) {
Toast.makeText(getBaseContext(), "ERROR - Could not create Bluetooth
socket", Toast.LENGTH_SHORT).show();
}
try {
btSocket.connect();
} catch (IOException e) {
try {
btSocket.close();
//If IO exception occurs attempt to close socket
} catch (IOException e2) {
Toast.makeText(getBaseContext(), "ERROR - Could not close Bluetooth
socket", Toast.LENGTH_SHORT).show();
}
}
try {
outStream = btSocket.getOutputStream();
} catch (IOException e) {
Toast.makeText(getBaseContext(), "ERROR - Could not create bluetooth
outstream", Toast.LENGTH_SHORT).show();
}
}

@Override
public void onPause() {
super.onPause();
//Pausing can be the end of an app if the device kills it or the user doesn't open it
again
//close all connections so resources are not wasted
Log.i("State : ", "On Pause");
//Close BT socket to device
try {
btSocket.close();

} catch (IOException e2) {


Toast.makeText(getBaseContext(), "ERROR - Failed to close Bluetooth socket",
Toast.LENGTH_SHORT).show();
}
}

private BluetoothSocket createBluetoothSocket(BluetoothDevice device) throws


IOException {
return device.createRfcommSocketToServiceRecord(MY_UUID);
}
private void checkBTState() {
// Check device has Bluetooth and that it is turned on
if(btAdapter==null) {
Toast.makeText(getBaseContext(), "ERROR - Device does not support
bluetooth", Toast.LENGTH_SHORT).show();
finish();
} else {
if (btAdapter.isEnabled()) {
} else {
//Prompt user to turn on Bluetooth
Intent enableBtIntent = new
Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, 1);
}
}
}

//

//

private void sendData(String message) {


Toast.makeText(this, message, 1000).show();
byte[] msgBuffer = message.getBytes();
try {
//attempt to place data on the outstream to the BT device
outStream.write(msgBuffer);
Toast.makeText(this, "Sending Succes", 1000).show();
try {
Thread.sleep(50);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (IOException e) {
//if the sending fails this is most likely because device is no longer there
Toast.makeText(getBaseContext(), "ERROR - Device not found",

Toast.LENGTH_SHORT).show();
finish();
}
}

@Override
public void onProgressChanged(SeekBar seekbar, int progress,
boolean fromUser) {
// TODO Auto-generated method stub
edR = (EditText) findViewById(R.id.edR);
edG = (EditText) findViewById(R.id.edG);
edB = (EditText) findViewById(R.id.edB);
if(seekbar == sRedP||seekbar == sGreenP||seekbar == sBlueP){
edR.setText(""+sRedP.getProgress());
edG.setText(""+sGreenP.getProgress());
edB.setText(""+sBlueP.getProgress());
try{
sendData(sRedP.getProgress()+":"+sGreenP.getProgress()+":"
+sBlueP.getProgress()+":99;");
}catch(Exception e){
Toast.makeText(getBaseContext(), e.getMessage(),
Toast.LENGTH_SHORT).show();
}
}
}
@Override
public void onStartTrackingTouch(SeekBar arg0) {
// TODO Auto-generated method stub
}
@Override
public void onStopTrackingTouch(SeekBar arg0) {
// TODO Auto-generated method stub
}
}

package com.qiqi.hydrophonicbt;
import java.util.ArrayList;
import java.util.List;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import android.widget.ListView;

public class DBAdapter {


public static final String KEY_ROWID = "_id";
public static final String KEY_Nama = "nama";
public static final String KEY_Code = "code";
public static final String KEY_Time = "time";
private static final String TAG = "DBAdapter";
private static final String DATABASE_NAME = "Hydrophonik";
private static final String DATABASE_TABLE = "color_code";
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_CREATE =
"CREATE TABLE color_code (_id INTEGER PRIMARY KEY
AUTOINCREMENT,"
+ " nama TEXT NOT NULL UNIQUE,"
+ " code TEXT NOT NULL," +
" time TEXT NOT NULL);";
private Context context;
private DatabaseHelper DBHelper;
private SQLiteDatabase db;
public DBAdapter(Context ctx){
this.context = ctx;
DBHelper = new DatabaseHelper(context);
}
private static class DatabaseHelper extends SQLiteOpenHelper{
DatabaseHelper(Context context){
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override

public void onCreate(SQLiteDatabase db) {


db.execSQL(DATABASE_CREATE);
// TODO Auto-generated method stub
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.w(TAG, "Upgrading database from version " + oldVersion
+ " to " + newVersion + ", which will destroy all old
data");
db.execSQL("DROP TABLE IF EXISTS color_code");
onCreate(db);
// TODO Auto-generated method stub
}
}
public DBAdapter open() throws SQLException{
db = DBHelper.getWritableDatabase();
return this;
}
public void close(){
DBHelper.close();
}

public long insertList(String nama, String code, String time){


ContentValues initialValues = new ContentValues();
initialValues.put(KEY_Nama, nama);
initialValues.put(KEY_Code, code);
initialValues.put(KEY_Time, time);
return db.insert(DATABASE_TABLE, null, initialValues);
}
public boolean deleteList(String nama){
return db.delete(DATABASE_TABLE, KEY_Nama + " = '" + nama+"'",
null) > 0;
}
public List getAllPelanggan(){
List lp = new ArrayList();
Cursor cursor = db.query(DATABASE_TABLE, new String[]{
KEY_ROWID,
KEY_Nama,

KEY_Code,
KEY_Time
}, null, null, null, null, KEY_Nama);
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
ListProfile pel = parseListProfile(cursor);
lp.add(pel);
cursor.moveToNext();
}
cursor.close();
return lp;
}
private ListProfile parseListProfile(Cursor cursor) {
ListProfile lp = new ListProfile();
lp.setNama((cursor.getString(1)));
lp.setId(cursor.getInt(0));
return lp;
}
public boolean updateList(String oldName, String nama, String code, String time){
ContentValues args = new ContentValues();
args.put(KEY_Nama, nama);
args.put(KEY_Code, code);
args.put(KEY_Time, time);
return db.update(DATABASE_TABLE, args,
KEY_Nama + " = '"+ oldName +"'", null) > 0;
}

public Cursor getCode(String Nama) throws SQLException{


Cursor mCursor =
db.query(true, DATABASE_TABLE, new String[]{
KEY_ROWID,
KEY_Nama,
KEY_Code,
KEY_Time
}, KEY_Nama + " = '" + Nama + "'",
null, null, null, null, null);
if(mCursor != null){
mCursor.moveToFirst();
}
return mCursor;
}

package com.qiqi.hydrophonicbt;
publicclass ListProfile {
private String nama;
privateintid;
public String getNama(){
return (nama);
}
publicint getId(){
return (id);
}
publicvoid setNama(String nama){
this.nama=nama;
}
publicvoid setId(int id){
this.id=id;
}
public String toString(){
return (getNama());
}

package com.qiqi.hydrophonicbt;
import java.util.StringTokenizer;
import java.util.*;
public class PisahKata
{
Vector v=new Vector(10);
public void Pisah(String x)
{
StringTokenizer token = new StringTokenizer(x, ":");
while (token.hasMoreTokens())
{
v.add(token.nextToken());
}
}
}

<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/baru"
tools:context="com.qiqi.hydrophonic.MainActivity">
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="45dp">
<RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="@+id/rbLED1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Led1"/>
<RadioButton
android:id="@+id/rbLED2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Led2"/>
<RadioButton
android:id="@+id/rbLED3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Led3"/>
<RadioButton
android:id="@+id/rbAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Semua"/>
</RadioGroup>
</LinearLayout>
<Button
android:id="@+id/BSubmit"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"

android:layout_alignRight="@+id/linearLayout1"
android:onClick="Submit"
android:layout_marginBottom="5dp"
android:text="ON"/>
<Button
android:id="@+id/BReset"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/BSubmit"
android:layout_alignBottom="@+id/BSubmit"
android:layout_alignLeft="@+id/linearLayout1"
android:onClick="Reset"
android:text="OFF"/>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:text="Pilih Jenis Tanaman"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<Spinner
android:id="@+id/spinK"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/linearLayout1"
android:layout_marginTop="55dp"/>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/spinK"
android:layout_below="@+id/linearLayout1"
android:layout_marginTop="34dp"
android:text="Jenis Tanaman"
android:textAppearance="?android:attr/textAppearanceMedium"/>

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/spinK"
android:layout_below="@+id/spinK"
android:layout_marginTop="20dp"
android:text="Nama Tanaman"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<LinearLayout
android:id="@+id/lnSJ"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignLeft="@+id/textView3"

android:layout_below="@+id/textView3"
android:layout_marginTop="10dp">
<Spinner
android:id="@+id/spinJ"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_gravity="left"
android:layout_marginRight="25dp"
android:gravity="center_vertical"
android:layout_weight="1"/>
<ImageView
android:id="@+id/imageView1"
android:layout_width="50dp"
android:layout_height="50dp"
android:onClick="options"
android:layout_weight="1"
android:src="@drawable/abc_ic_menu_moreoverflow_normal_holo_light"/>
</LinearLayout>
<Switch
android:id="@+id/switch1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/spinK"
android:layout_below="@+id/lnSJ"
android:layout_marginTop="18dp"
android:text="Timer"/>
</RelativeLayout>

<?xmlversion="1.0"encoding="utf-8"?>
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/baru"
>
<Button
android:id="@+id/btScan"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="Scan"
/>"
<TextViewandroid:id="@+id/title_paired_devices"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Select btSerial device from paired devices:"
android:visibility="gone"
android:background="#666"
android:textColor="#fff"
android:paddingLeft="5dp"
/>

<ListViewandroid:id="@+id/paired_devices"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stackFromBottom="false"
android:layout_weight="1"
/>
<TextView
android:id="@+id/connecting"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<TextView
android:id="@+id/infoText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="If no devices are listed please pair your device in Android
settings"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
</LinearLayout>
</LinearLayout>

<?xmlversion="1.0"encoding="utf-8"?>
<RelativeLayout
android:id="@+id/textMulai"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/baru"
xmlns:android="http://schemas.android.com/apk/res/android">
<AbsoluteLayout
android:id="@+id/abLayout"
android:layout_width="match_parent"
android:layout_height="128dp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/tv1"
android:layout_marginTop="20dp">
<EditText
android:id="@+id/edNama"
android:layout_width="206dp"
android:layout_height="wrap_content"
android:textSize="18sp"
android:layout_x="105dp"
android:layout_y="1dp"/>
<TextView
android:id="@+id/tvNama"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

android:text="Nama Profile"
android:layout_x="6dp"
android:layout_y="12dp"/>
<TextView
android:id="@+id/tvCode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="8dp"
android:layout_y="58dp"
android:text="Kode RGB"/>
<EditText
android:id="@+id/edR"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:layout_x="105dp"
android:layout_y="44dp"
android:ems="10"
android:inputType="number"
android:maxLength="3"
android:textSize="18sp">
</EditText>
<EditText
android:id="@+id/edG"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:layout_x="182dp"
android:layout_y="44dp"
android:ems="10"
android:inputType="number"
android:maxLength="3"
android:textSize="18sp"/>
<EditText
android:id="@+id/edB"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:layout_x="258dp"
android:layout_y="44dp"
android:ems="10"
android:inputType="number"
android:maxLength="3"
android:textSize="18sp"/>
</AbsoluteLayout>
<TextView
android:id="@+id/tv1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Profile"
android:textSize="24sp"
android:typeface="sans"
android:gravity="center"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"/>

<SeekBar
android:id="@+id/seekBp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:max="255"
android:layout_below="@+id/seekGp"
android:background="#0000ff"
android:layout_marginTop="18dp"/>
<SeekBar
android:id="@+id/seekGp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:max="255"
android:layout_below="@+id/seekRp"
android:background="#00ff00"
android:layout_marginTop="18dp"/>
<SeekBar
android:id="@+id/seekRp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/abLayout"
android:background="#ff0000"
android:max="255"/>
<TextView
android:id="@+id/txtMulai"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/seekBp"
android:layout_marginLeft="15dp"
android:layout_marginTop="34dp"
android:text="Hidup Mulai"/>
<TextView
android:id="@+id/tvSelesai"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/txtMulai"
android:layout_below="@+id/txtMulai"
android:layout_marginTop="23dp"
android:text="Sampai"/>
<Spinner
android:id="@+id/JamMulai"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/txtMulai"
android:layout_alignParentRight="true"
android:layout_marginRight="110dp"/>
<Spinner
android:id="@+id/MenitMulai"
android:layout_width="75dp"

android:layout_height="wrap_content"
android:layout_alignBottom="@+id/txtMulai"
android:layout_alignParentRight="true"
android:layout_marginRight="30dp"/>
<Spinner
android:id="@+id/JamSelesai"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/tvSelesai"
android:layout_alignParentRight="true"
android:layout_marginRight="110dp"/>
<Spinner
android:id="@+id/MenitSelesai"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/tvSelesai"
android:layout_alignParentRight="true"
android:layout_marginRight="30dp"/>
</RelativeLayout>

<?xmlversion="1.0"encoding="utf-8"?>
<TextViewxmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="18sp"
android:padding="5dp">
</TextView>