Translate

Membuat Alat Barcode Scanner Menggunakan MCR12 dan Barcode ITF14 ARDUINO

Membuat Alat Barcode Scanner Menggunakan MCR12 dan Barcode ITF14 ARDUINO


        Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang digunakan untuk membaca barcode itf14 dengan menggunakan barcode scanner MCR12 dan mikrokontroller yang digunakan adalah Arduino Mega. jadi alat ini hanya untuk membaca barcode dengan jenis itf14 saja karena panjang data berjumlah 14, jika ingin digunakan untuk membaca barcode jenis lain bisa dirubah pada pembatasan pembacaan data di program, pada contoh terdapat pembatasan pembacaan karakter sejumlah 14 data. untuk lebih jelasnya berikut adalah skema dan programnya. 




a. Arduino Mega





b. Barcode Scanner MCR12





c. LCD 16x2





d. Rangkaian Serial RS232 




 
e. Barcode ITF14






f. Program Arduino IDE

#include "Wire.h"
#include <LiquidCrystal.h>
LiquidCrystal lcd(11, 12, 4, 5, 6, 7);

String inputString = "";         // a string to hold incoming data
boolean stringComplete = false;  // whether the string is complete
String barcode;

void setup() {
  lcd.begin(16, 2);
  lcd.clear();
  lcd.noCursor();
 
  Serial.begin(9600);
  inputString.reserve(200);
}

void loop() {
  lcd.setCursor(0, 0);
  lcd.print("MCR-12 SCANNER");


  if (stringComplete) {
    Serial.println(inputString);
    barcode = inputString.substring(0,14);
    lcd.setCursor(0, 1);
    lcd.print(barcode);
    delay(5000);
    inputString = "";
    stringComplete = false;
  }
}


void serialEvent() {
  while (Serial.available()) {
    char inChar = (char)Serial.read();
    inputString += inChar;
    if (inChar == '\n') {
      stringComplete = true;
    }
  }
}





g. VIDEO HASILNYA






 






Membuat Digital Spirometri Peak Flow Meter / Alat Pengukur Tekanan Paru-paru dan Data Logger SD CARD

Membuat Digital Spirometri Peak Flow Meter / Alat Pengukur Tekanan Paru-paru dan Data Logger SD CARD


     Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang berfungsi sebagai pengukur tekanan paru-paru atau spiromeri digital dengan parameter yang digunakan yaitu umur, jenis kelamin, dan tinggi badan, sehingga didapatkan PEF atau peak flow meter normalnya menggunakan rumus yang tersedia. alat ini menggunakan sensor MPX5100 dan penyimpanan datanya menggunakan SD Card. untuk lebih jelasnya berikut adalah skema dan programnya. 




a. Arduio Uno





b. Sensor MPX5100





c. LCD 8x2





d. Modul SD CARD 






e. Program Arduino IDE

 #include <LiquidCrystal.h>
#include <SPI.h>
#include <SD.h>
LiquidCrystal lcd(5,A4,3,2,A2,A3);

int btup = 9;
int btdown = 6;
int btenter = 8;

int btupx = 0;
int btdownx = 0;
int btenterx = 0;

int dataadc;
int x = 1;
int y = 13;
int z = 150;
int simpanx,simpany,simpanz;
float pef;
float vol;
float kpa;
float lt;

File myFile;



void setup() {
 
 //Serial.begin(9600);

 lcd.begin(8,2);
 lcd.clear();
 lcd.noCursor();

pinMode(btup,INPUT);
pinMode(btdown,INPUT);
pinMode(btenter,INPUT);

//digitalWrite(btup,HIGH);
//digitalWrite(btdown,HIGH);
//digitalWrite(btenter,HIGH);

}


void loop() {

  // put your main code here, to run repeatedly:
  lcd.clear();
  jk();
  delay(1000);
  umur();
  delay(1000);
  tinggi();
  delay(1000);
  mulai();
  delay(1000);

}




void jk(){
 
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btenterx = digitalRead(btenter);
 
lcd.setCursor(0,0);
lcd.print("SET P/W");

if(btupx == 1){
delay(200);
x++;
if(x > 2){
x = 1;
}
}

if(btdownx == 1){
delay(200);
x--;
if(x < 1){
x = 2;
}
}

if(x == 1){
lcd.setCursor(0,1);
lcd.print("PRIA       ");
}

if(x == 2){
lcd.setCursor(0,1);
lcd.print("WANITA     ");
}


if(btenterx == 1){
delay(200);
lcd.clear();
simpanx = x;
return;
}


jk();
}



void umur(){

btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btenterx = digitalRead(btenter);
 
lcd.setCursor(0,0);
lcd.print("SET UMUR");

if(btupx == 1){
delay(200);
y++;
if(y > 70){
y = 70;
}
}

if(btdownx == 1){
delay(200);
y--;
if(y < 13){
y = 13;
}
}

lcd.setCursor(0,1);
lcd.print(y);


if(btenterx == 1){
delay(200);
lcd.clear();
simpany = y;
return;
}


umur();
}



void tinggi(){

btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btenterx = digitalRead(btenter);
 
lcd.setCursor(0,0);
lcd.print("S TINGGI");

if(btupx == 1){
delay(200);
z++;
if(z > 170){
z = 170;
}
}

if(btdownx == 1){
delay(200);
y--;
if(y < 150){
y = 150;
}
}

lcd.setCursor(0,1);
lcd.print(z);


if(btenterx == 1){
delay(200);
lcd.clear();
simpanz = z;
return;
}
 
 
 
tinggi();
}



void mulai(){

btupx = digitalRead(btup);

if(simpanx == 1){
pef = -10.86040 + 0.12766 * simpany + 0.11169 * simpanz - 0.0000319344 * simpany * simpany * simpany;
}

if(simpanx == 2){
pef = -5.12502 + 0.09006 * simpany + 0.06980 * simpanz - 0.00145669 * simpany * simpany;
}

 
 dataadc = analogRead(A0);
 vol = dataadc * (5.0 / 1023.0);
 kpa = (( vol - 0.2) / 0.045 )* 0.1971621298;
 

lcd.setCursor(0,0);
lcd.print("T=");
lcd.print(kpa);

lcd.setCursor(0,1);
lcd.print("H=");
lcd.print(pef,2);
 
delay(200);

if(btupx == 1){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("saving.....");
delay(3000);


  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  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) {
  
    if(simpanx == 1){
    myFile.print("Jenis Kelamin = ");
    myFile.println("PRIA");
    }
    if(simpanx == 2){
    myFile.print("Jenis Kelamin = ");
    myFile.println("WANITA");
    }
    myFile.print("Umur = ");
    myFile.println(y);
    myFile.print("Tinggi = ");
    myFile.println(z); 
    myFile.print("Hasil PEF = ");
    myFile.println(kpa);
    myFile.print("PEF Normal = ");
    myFile.println(pef);
    myFile.println(" ");
     
    // close the file:
    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }

  // re-open the file for reading:
  myFile = SD.open("test.txt");
  if (myFile) {
    Serial.println("test.txt:");

    // read from the file until there's nothing else in it:
    while (myFile.available()) {
      Serial.write(myFile.read());
    }
    // close the file:
    myFile.close();
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }

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


mulai();
}





f. VIDEO HASILNYA











Membuat Alat Monitoring Suhu via INTERNET Menggunakan Arduino dan Ethernet Webserver (IOT)

Membuat Alat Monitoring Suhu via INTERNET Menggunakan Arduino dan Ethernet Webserver (IOT)


          Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang berbasis mikrokontroller menggunakan jaringan internet sebagai media penghubungnya, jadi tidak ada batas jarak atau batasan maksimal jarak karena menggunakan media internet, yang bisa berpengaruh pada transfer datanya yaitu hanya koneksi dan sinyal internet saja, jika sinyal lemah maka akan menganggu proses transfer data suhunya, namun jika koneksi cepat maka tidak akan ada masalah pada transfer datanya, pada alat ini menggunakan sensor suhu lm35 dan ethernet shield sebagai media penghubung ke router, jadi alat ini hanya mengirimkan data suhu ke server. untuk lebih jelasnya berikut adalah program dan skemanya.




a. Arduino Mega + Ethernet Shield





b. Sensor Suhu LM35





c. Router + Modem






d. Program Arduino IDE

#include <SPI.h>
#include <Ethernet.h>

String txData2="";

byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
  char server[] = "www.viskositasoliku.hol.es";
IPAddress ip(192,168,0,99);

EthernetClient client;

void setup() {
  
  Serial.begin(9600);
  while (!Serial) {
    ;
  }

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    Ethernet.begin(mac, ip);
  }

    delay(1000);
    Serial.println("connecting...");
    kirim ();
  
  }

void loop()
{     
  kirim ();
}


void kirim (){

  int dataadc = analogRead(A0);
  float voltage0x = dataadc * (5.0/1023.0) * 100;
  int voltage0 = voltage0x * 100;
 
  EthernetClient client;

if (client.connect(server, 80)){
    txData2 = "voltage0="+ (String (voltage0));           
    Serial.println("connected");
    Serial.print(txData2);
    client.println("POST /insertx.php HTTP/1.1");
    client.println("Host: www.viskositasoliku.hol.es");
    client.println("Connection: close");
    client.print("Content-Type: application/x-www-form-urlencoded\n");
    client.print("Content-Length: ");
    client.print(txData2.length());
    client.print("\n\n");
    client.print(txData2);
    Serial.println(txData2);    
    delay (20000);
        
  }  
  else{
    Serial.println("Connection Failed.");
    Serial.println();
    delay (1500);
  }
}




e. config.php

<?php

$dbhost = 'mysql.idhostinger.com';
$dbuser = 'u141xxxx_user';
$dbpass = '1234567890';  
$dbname = 'u141xxxx_mydb';

$conn = @mysql_connect($dbhost,$dbuser,$dbpass) or die ('Error connecting to mysql');
mysql_select_db($dbname);
if(!$conn){
        echo "database gak konek";
    }else{

    }
?>




f. insertx.php

<?php
require("config.php");

$query = "INSERT INTO tbvisko (voltage0) VALUES('$_POST[voltage0]')";


if(!@mysql_query($query))
{
    echo "&Answer; SQL Error - ".mysql_error();
    return;
}

?>




g. index.php

 <html>
<head>
<meta http-equiv="refresh" content="3">
<style>
.bordered { border-style:solid; }
</style>
<link rel="stylesheet" type="text/css" href="latweb.css" />
<title >MONITORING SUHU</title>
</head>
<body>

<CENTER>
<p><h2> MONITORING SUHU</h2></p>

<br>
<input type="button" onclick="location.href='http://viskositasoliku.hol.es/dbshow.php';" value="Lihat Database" />
<br>
</CENTER>

<CENTER>
<p><h3>

VISKOSITAS =
<?php
include "config.php";
$tampil = @mysql_query("SELECT * FROM tbvisko WHERE no IN (SELECT MAX(no) FROM tbvisko)");
        
    while ($r=mysql_fetch_array($tampil)){
       echo "$r[voltage0]";
   }
?>

</CENTER>

</body>

</html>




h. dbshow,php

<html>
<head>
<meta http-equiv="refresh" content="3">
<style>
.bordered { border-style:solid; }
</style>
<title >DATABASE</title>
</head>
<body bgcolor = #ffaaff>

<CENTER>
<p><h2> DATABASE VISKOSITAS OLI</h2></p>

<br>
<input type="button" onclick="location.href='http://viskositasoliku.hol.es/index.php';" value=" HOME " />
<br>
<br>
<br>

<?php
include "config.php";

$tampil = mysql_query("SELECT * FROM tbvisko");

 echo "<table border = '1'>
          <tr><th bgcolor = #C87C5B>GAS CO</th></tr>";
 
    while ($r=mysql_fetch_array($tampil)){
       echo "<tr>
             <td bgcolor = #FFC848>$r[voltage0]</td></tr>";
    }
    echo "</table>";

@mysql_close($con);

?>

</CENTER>
</body>
</html>






i. Gambar Hasilnya







j. Video Hasilnya














Tutorial Fuzzy Logic Control Mamdani Menggunakan Matlab Tools

Tutorial Fuzzy Logic Control Mamdani Menggunakan Matlab Tools


          Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah aplikasi yang menggunakan fuzzy logic tools untuk sebuah permasalahan atau diagnosa, yang akan dicontohkan kali ini yaitu bagaimana cara menggunakan fuzzy logic control menggunakan matlab pada kasus diagnosa diabetes dengan variabel inputnya yaitu umur, berat badan dan tekanan darah, dari ketiga faktor tersebut dapat didiagnosa apakah seseorang atau pasien tersebut rentan terkena diabetes ataukah tidak, dengan menggunakan matlab maka semua kemungkinan tersebut dapat diatasi dengan derajat keanggotaannya, jadi akan terlihat kecenderungannya melalui nilai hasil fuzzy-nya sehingga dapat disimpulkan apakah pasien ada kecenderungan mengidap diabetes ataukah tidak. sebenarnya case ini diambil dari sebuah jurnal yang mana jurnal tersebut sudah dipublikasi artinya jurnal tersebut telah melalui serangkaian penelitian sehingga kita bisa pastikan keakuratan datanya. berikut adalah caranya.




a. Membuat Membership Function Input









b. Membership Function Output

  




b. Membuat Membership Function Input di Matlab








c. Membuat Membership Function Output di Matlab






d. Membuat Fuzzy Rule










e. OUTPUT FUZZY







f. VIDEO HASILNYA











Membuat Tempat Sampah Otomatis Buka - Tutup dan Alarm Penuh ( SMART TRASH BIN )

Membuat Tempat Sampah Otomatis Buka - Tutup dan Alarm Penuh ( SMART TRASH BIN )


      Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat berfungsi sebagai tempat sampah pintar yang mana jika ada orang yang ingin membuang sampah maka pada jarak tertentu, tutup tempat sampah akan membuka dengan sendirinya, kemudian jika orang tersebut telah menjauh maka akan menutup dengan sendirinya, terdapat 2 buah indikator yang menandakan tempat sampah kondisi penuh atau kosong, jika sudah penuh maka akan ada alarm yang berbunyi dan led merah akan menyala, namun jika kondisi tempat sampah kosong atau belum penuh maka led hijau akan menyala. untuk sensor yang digunakan adalah HY-SRF05 sebanyak 4 buah, yaitu untuk bagian kanan, kiri, depan dan bagian atas. untuk deteksi orang yang mendekat digunakan sensor jarak yang berada di kanan, kiri dan depan sedangkan untuk sensor volumenya menggunakan sensor yang terdapat diatas. untuk lebih jelasnya berikut adalah skema dan programnya.




a. Arduino Uno






b. Sensor Jarak HY-SRF05





c. Motor Servo





d. LCD 16 x 2 + I2C Converter





e. UBEC 3A





f. Led dan Buzzer






g. Program Arduino IDE

#include <Wire.h>  // i2C Conection Library
#include <LiquidCrystal_I2C.h>  //i2C LCD Library
#include <Servo.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

Servo myservo; 

const int TRIG_PIN1 = 2;
const int ECHO_PIN1 = 3;
const int TRIG_PIN2 = 4;
const int ECHO_PIN2 = 5;
const int TRIG_PIN3 = 6;
const int ECHO_PIN3 = 7;
const int TRIG_PIN4 = A1;
const int ECHO_PIN4 = A0;

int ledm = 11;
int ledh = 10;
int buzzer = 8;

long duration1, distanceCm1;
long duration2, distanceCm2;
long duration3, distanceCm3;
long duration4, distanceCm4;

void setup() {
  myservo.attach(9);

  lcd.begin();
  lcd.noCursor();
  lcd.clear();
 
  pinMode(TRIG_PIN1,OUTPUT);
  pinMode(ECHO_PIN1,INPUT);
  pinMode(TRIG_PIN2,OUTPUT);
  pinMode(ECHO_PIN2,INPUT);
  pinMode(TRIG_PIN3,OUTPUT);
  pinMode(ECHO_PIN3,INPUT);
  pinMode(TRIG_PIN4,OUTPUT);
  pinMode(ECHO_PIN4,INPUT);
  pinMode(ledm,OUTPUT);
  pinMode(ledh,OUTPUT);
  pinMode(buzzer,OUTPUT);
  digitalWrite(buzzer,HIGH);
  
   myservo.write(100);

}


void loop()
{

  digitalWrite(TRIG_PIN1, LOW);
  delayMicroseconds(2);
  digitalWrite(TRIG_PIN1, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIG_PIN1, LOW);
  duration1 = pulseIn(ECHO_PIN1,HIGH);

  // convert the time into a distance
  distanceCm1 = duration1 / 29.1 / 2 ;

  digitalWrite(TRIG_PIN2, LOW);
  delayMicroseconds(2);
  digitalWrite(TRIG_PIN2, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIG_PIN2, LOW);
  duration2 = pulseIn(ECHO_PIN2,HIGH);

  // convert the time into a distance
  distanceCm2 = duration2 / 29.1 / 2 ;


  digitalWrite(TRIG_PIN3, LOW);
  delayMicroseconds(2);
  digitalWrite(TRIG_PIN3, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIG_PIN3, LOW);
  duration3 = pulseIn(ECHO_PIN3,HIGH);

  // convert the time into a distance
  distanceCm3 = duration3 / 29.1 / 2 ;


  digitalWrite(TRIG_PIN4, LOW);
  delayMicroseconds(2);
  digitalWrite(TRIG_PIN4, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIG_PIN4, LOW);
  duration4 = pulseIn(ECHO_PIN4,HIGH);

  // convert the time into a distance
  distanceCm4 = duration4 / 29.1 / 2 ;


 lcd.setCursor(0,0);
 lcd.print(distanceCm1);

 lcd.setCursor(0,1);
 lcd.print(distanceCm2);

 lcd.setCursor(8,0);
 lcd.print(distanceCm3);

 lcd.setCursor(8,1);
 lcd.print(distanceCm4);


  if(distanceCm4 <= 10 ){
  digitalWrite(ledm,HIGH); 
  digitalWrite(ledh,LOW); 
  }

  if(distanceCm4 > 5 ){
  digitalWrite(ledh,HIGH);
  digitalWrite(ledm,LOW);
  digitalWrite(buzzer,HIGH);
  
  }
 
  if((distanceCm4 <= 5 )&&(distanceCm1 < 50)&&(distanceCm2 > 50)&&(distanceCm3 > 50)){
  digitalWrite(buzzer,LOW); 
  }
  if((distanceCm4 <= 5 )&&(distanceCm1 > 50)&&(distanceCm2 < 50)&&(distanceCm3 > 50)){
  digitalWrite(buzzer,LOW); 
  }
  if((distanceCm4 <= 5 )&&(distanceCm1 > 50)&&(distanceCm2 > 50)&&(distanceCm3 < 50)){
  digitalWrite(buzzer,LOW); 
  }
 
  if((distanceCm4 <= 5 )&&(distanceCm1 < 50)&&(distanceCm2 < 50)&&(distanceCm3 > 50)){
  digitalWrite(buzzer,LOW); 
  }
  if((distanceCm4 <= 5 )&&(distanceCm1 < 50)&&(distanceCm2 > 50)&&(distanceCm3 < 50)){
  digitalWrite(buzzer,LOW); 
  }
  if((distanceCm4 <= 5 )&&(distanceCm1 > 50)&&(distanceCm2 < 50)&&(distanceCm3 < 50)){
  digitalWrite(buzzer,LOW); 
  }
  if((distanceCm4 <= 5 )&&(distanceCm1 < 50)&&(distanceCm2 < 50)&&(distanceCm3 < 50)){
  digitalWrite(buzzer,LOW); 
  }
  if((distanceCm4 <= 5 )&&(distanceCm1 > 50)&&(distanceCm2 > 50)&&(distanceCm3 > 50)){
  digitalWrite(buzzer,HIGH); 
  }
 
  //=============================================================================================
  if((distanceCm4 > 5 )&&(distanceCm1 < 50)&&(distanceCm2 > 50)&&(distanceCm3 > 50)){
    myservo.write(150);
  }
  if((distanceCm4 > 5 )&&(distanceCm1 > 50)&&(distanceCm2 < 50)&&(distanceCm3 > 50)){
    myservo.write(150); 
  }
  if((distanceCm4 > 5 )&&(distanceCm1 > 50)&&(distanceCm2 > 50)&&(distanceCm3 < 50)){
    myservo.write(150); 
  }
 
  if((distanceCm4 > 5 )&&(distanceCm1 < 50)&&(distanceCm2 < 50)&&(distanceCm3 > 50)){
    myservo.write(150); 
  }
  if((distanceCm4 > 5 )&&(distanceCm1 < 50)&&(distanceCm2 > 50)&&(distanceCm3 < 50)){
    myservo.write(150);
  }
  if((distanceCm4 > 5 )&&(distanceCm1 > 50)&&(distanceCm2 < 50)&&(distanceCm3 < 50)){
    myservo.write(150); 
  }
  if((distanceCm4 > 5 )&&(distanceCm1 < 50)&&(distanceCm2 < 50)&&(distanceCm3 < 50)){
    myservo.write(150);
  }
  if((distanceCm4 > 5 )&&(distanceCm1 > 50)&&(distanceCm2 > 50)&&(distanceCm3 > 50)){
    myservo.write(100); 
  }
 

  delay(1000);
  lcd.clear();

}







h. VIDEO HASILNYA











  

Membuat Alat Kendali Peralatan Rumah Tangga / RELAY Menggunakan WIFI dengan INPUT Jadwal Jam ON / OFF WEBSERVER ARDUINO

Membuat Alat Kendali Peralatan Rumah Tangga / RELAY Menggunakan WIFI dan  INPUT Jadwal  /Jam ON - OFF WEBSERVER ARDUINO RTC


       Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang menggunakan wifi sebagai media alat kendali ON/OFF device dengan input jadwalnya menggunakan browser, jadi sistemnya yaitu webserver yang mana user bisa memasukkan jam dan tanggal kapan alat hidup dan kapan alat mati secara otomatis dengan menggunakan browser, koneksi yang digunakan yaitu wifi sehingga memudahkan user untuk instalasinya, alat ini menggunakan Arduino sebagai kontrollernya dan ethernet shield sebagai jembatan menuju ke WIFI. alat ini juga dilengkapi dengan RTC DS1302 dan 4 buah relay sebagai kendali device, jadi jika jam sekarang sudah sama dengan jam yang diinputkan maka device akan on/off sesuai jadwal yang dimasukkan. untuk lebih jelasnya berikut adalah skema dan programnya.




a. Arduino Mega





b. RTC DS1302





c. Ethernet Shield





d. Modul Relay





e.  Router






f. Program Arduino IDE

-PROGRAM INPUT JADWAL

#include <SPI.h>
#include <Ethernet.h>
#include <Wire.h>
#include <DS1302.h>

// Init the DS1302
DS1302 rtc(2, 3, 4);

int onkip;
int offkip;
int onkul;
int offkul ;
int onlt;
int offlt;
int onls;
int offls;


byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 0, 102 }; // ip in lan
byte gateway[] = { 192, 168, 0, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(80);; //server port

String readString;
Time t;


void setup(void){

  pinMode(A0,OUTPUT);
  pinMode(A1,OUTPUT);
  pinMode(A2,OUTPUT);
  pinMode(A3,OUTPUT);
   
  rtc.halt(false);
  rtc.writeProtect(false);

  // The following lines can be commented out to use the values already stored in the DS1302
  rtc.setDOW(WEDNESDAY);        // Set Day-of-Week to FRIDAY
  rtc.setTime(20, 59, 0);     // Set the time to 12:00:00 (24hr format)
  rtc.setDate(4, 5, 2017);   // Set the date to August 6th, 2010
 
  rtc.writeProtect(true);
 
  Wire.begin();

  Ethernet.begin(mac, ip, gateway, subnet);
  server.begin();

  //enable serial data print
  Serial.begin(9600);
  Serial.println("servertest1"); // so I can keep track of what is loaded
}



void loop(void){

t = rtc.getTime();

  // Create a client connection
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

        //read char by char HTTP request
        if (readString.length() < 100) {

          //store characters to string
          readString += c;

        }

        //if HTTP request has ended
        if (c == '\n') {

          ///////////////
          Serial.println(readString);

          //now output HTML data header

          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");
          client.println("Refresh: 1");        
          client.println();

          client.println("<HTML>");
          client.println("<HEAD>");
          client.println("<TITLE>INPUT JADWAL</TITLE>");
          client.println("</HEAD>");
          client.println("<BODY>");

          client.println("<H3>kontrol ON / OFF dan delay lampu");
          client.println("<BR>");
          client.print(rtc.getTimeStr());
          client.print(" ");
          client.println(rtc.getDOWStr(FORMAT_LONG));
          client.print(" ");
          client.print(rtc.getDateStr(FORMAT_LONG,FORMAT_LITTLEENDIAN, '/'));

          client.println("<BR>");
         
          client.println("<BR></H3>");
          client.println("<FORM ACTION=\"http://192.168.0.102:80\" method=get >");

          client.println("JAM ON KIPAS  : <INPUT TYPE=TEXT NAME=\"onkip\" VALUE=\"A\" SIZE=\"25\" MAXLENGTH=\"50\"><BR><BR>");
          client.println("JAM OFF KIPAS: <INPUT TYPE=TEXT NAME=\"offkip\" VALUE=\"B\" SIZE=\"25\" MAXLENGTH=\"50\"><BR><BR>");
         
          client.println("JAM ON KULKAS : <INPUT TYPE=TEXT NAME=\"onkul\" VALUE=\"C\" SIZE=\"25\" MAXLENGTH=\"50\"><BR><BR>"); 
          client.println("JAM OFF KULKAS : <INPUT TYPE=TEXT NAME=\"offkul\" VALUE=\"D\" SIZE=\"25\" MAXLENGTH=\"50\"><BR><BR>");
         
          client.println("JAM ON Lampu Tengah : <INPUT TYPE=TEXT NAME=\"onlt\" VALUE=\"E\" SIZE=\"25\" MAXLENGTH=\"50\"><BR><BR>");
          client.println("JAM OFF Lampu Tengah : <INPUT TYPE=TEXT NAME=\"offlt\" VALUE=\"F\" SIZE=\"25\" MAXLENGTH=\"50\"><BR><BR>");

          client.println("JAM ON Lampu Teras : <INPUT TYPE=TEXT NAME=\"onls\" VALUE=\"G\" SIZE=\"25\" MAXLENGTH=\"50\"><BR><BR>");
          client.println("JAM OFF Lampu Teras : <INPUT TYPE=TEXT NAME=\"offls\" VALUE=\"H\" SIZE=\"25\" MAXLENGTH=\"50\"><BR><BR>");

          client.println("<INPUT TYPE=SUBMIT NAME=\"submit\" VALUE=\" SUBMIT\">");
        
          client.println("</FORM>");
          client.println("<BR>");
          client.println("<h5>");   
          client.println("SET ON KIPAS = ");
          client.println(onkip);
            client.println("<BR>");
          client.println("SET OFF KIPAS = ");
          client.println(offkip);
            client.println("<BR>");
          client.println("SET ON KULKAS = ");
          client.println(onkul);
            client.println("<BR>");
          client.println("SET OFF KULKAS = ");
          client.println(offkul);
            client.println("<BR>");
          client.println("SET ON LAMPU TENGAH = ");
          client.println(onlt);
            client.println("<BR>");
          client.println("SET OFF LAMPU TENGAH =");
          client.println(offlt);
            client.println("<BR>");
          client.println("SET ON LAMPU TERAS = ");
          client.println(onls);
            client.println("<BR>");
          client.println("SET OFF LAMPU TERAS =");
          client.println(offls);
            client.println("<BR>");
           
          client.println("</h5>");
          client.println("<BR>");

          client.println("</BODY>");
          client.println("</HTML>");

          delay(1);
          //stopping client

          client.stop();
        
        

        
          //==============================================
          if(readString.indexOf("A7") >0)//checks for on
          {
             onkip = 21;          
          }

                 
          if(readString.indexOf("B8") >0)//checks for on
          {
             offkip = 8;
          }
        
              
          if(readString.indexOf("C10") >0)//checks for on
          {
             onkul = 1000;
           
          }

                
          if(readString.indexOf("D2") >0)//checks for off
          {
             offkul = 2;
          }
        
        
          if(readString.indexOf("E2") >0)//checks for off
          {
            onlt = 2;
          }
         
          if(readString.indexOf("F2") >0)//checks for off
          {
            offlt = 2;
          }
         
          if(readString.indexOf("G2") >0)//checks for off
          {
            onls = 2;
          }
         
          if(readString.indexOf("H2") >0)//checks for off
          {
            offls = 2;
          }
         
          //===================================
        //   Serial.print(rtc.getDOWStr());
        //   Serial.print(" ");
        //   Serial.print(rtc.getDOWStr(FORMAT_LONG));
        //   Serial.print(" -- ");
        //   Serial.println(rtc.getTimeStr());
 
          if((t.hour == onkip)&&(t.hour > 0)){
          digitalWrite(A0,HIGH);
          }

        
          //clearing string for next read
          readString="";

        }
      }
    }
  }
}





- PROGRAM INPUT JADWAL + KENDALI + MONITORING ADC

#include <SPI.h>
#include <Ethernet.h>
#include <Wire.h>
#include <DS1302.h>

// Init the DS1302
DS1302 rtc(2, 3, 4);

int onkip;
int offkip;
int onkul;
int offkul ;
int onlt;
int offlt;
int onls;
int offls;


byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 0, 102 }; // ip in lan
byte gateway[] = { 192, 168, 0, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(80);; //server port

String readString;
Time t;


void setup(void){

  pinMode(A0,OUTPUT);
  pinMode(A1,OUTPUT);
  pinMode(A2,OUTPUT);
  pinMode(A3,OUTPUT);
   
  rtc.halt(false);
  rtc.writeProtect(false);

  // The following lines can be commented out to use the values already stored in the DS1302
  //rtc.setDOW(WEDNESDAY);        // Set Day-of-Week to FRIDAY
  //rtc.setTime(10, 20, 0);     // Set the time to 12:00:00 (24hr format)
  //rtc.setDate(12, 4, 2017);  

  rtc.writeProtect(true);
 
  Wire.begin();

  Ethernet.begin(mac, ip, gateway, subnet);
  server.begin();

  //enable serial data print
  Serial.begin(9600);
  Serial.println("servertest1"); // so I can keep track of what is loaded
}



void loop(void){
 
int dataadc = analogRead(A7);

t = rtc.getTime();

  // Create a client connection
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

        //read char by char HTTP request
        if (readString.length() < 100) {

          //store characters to string
          readString += c;

        }

        //if HTTP request has ended
        if (c == '\n') {

          ///////////////
          Serial.println(readString);

          //now output HTML data header

          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");
          client.println("Refresh: 1");        
          client.println();

          client.println("<HTML>");
          client.println("<HEAD>");
          client.println("<TITLE>INPUT JADWAL</TITLE>");
          client.println("</HEAD>");
          client.println("<BODY>");

          client.println("<H3>kontrol ON / OFF dan delay lampu");
          client.println("<BR>");
          client.print(rtc.getTimeStr());
          client.print(" ");
          client.println(rtc.getDOWStr(FORMAT_LONG));
          client.print(" ");
          client.print(rtc.getDateStr(FORMAT_LONG,FORMAT_LITTLEENDIAN, '/'));

          client.println("<BR>");
           client.println("ADC = ");
           client.println(dataadc);
          client.println("<BR></H3>");
         
          client.println("<FORM ACTION=\"http://192.168.0.102:80\" method=get >");

          client.println("JAM ON KIPAS  : <INPUT TYPE=TEXT NAME=\"onkip\" VALUE=\"A\" SIZE=\"25\" MAXLENGTH=\"50\"><BR><BR>");
          client.println("JAM OFF KIPAS: <INPUT TYPE=TEXT NAME=\"offkip\" VALUE=\"B\" SIZE=\"25\" MAXLENGTH=\"50\"><BR><BR>");
         
          client.println("JAM ON KULKAS : <INPUT TYPE=TEXT NAME=\"onkul\" VALUE=\"C\" SIZE=\"25\" MAXLENGTH=\"50\"><BR><BR>"); 
          client.println("JAM OFF KULKAS : <INPUT TYPE=TEXT NAME=\"offkul\" VALUE=\"D\" SIZE=\"25\" MAXLENGTH=\"50\"><BR><BR>");
         
          client.println("JAM ON Lampu Tengah : <INPUT TYPE=TEXT NAME=\"onlt\" VALUE=\"E\" SIZE=\"25\" MAXLENGTH=\"50\"><BR><BR>");
          client.println("JAM OFF Lampu Tengah : <INPUT TYPE=TEXT NAME=\"offlt\" VALUE=\"F\" SIZE=\"25\" MAXLENGTH=\"50\"><BR><BR>");

          client.println("JAM ON Lampu Teras : <INPUT TYPE=TEXT NAME=\"onls\" VALUE=\"G\" SIZE=\"25\" MAXLENGTH=\"50\"><BR><BR>");
          client.println("JAM OFF Lampu Teras : <INPUT TYPE=TEXT NAME=\"offls\" VALUE=\"H\" SIZE=\"25\" MAXLENGTH=\"50\"><BR><BR>");

          client.println("<INPUT TYPE=SUBMIT NAME=\"submit\" VALUE=\" SUBMIT\">");
        
          client.println("</FORM>");
          client.println("<BR>");
                  
          client.println("<a href = \"/?lighton1\"\"><input type = 'button' value = 'ON KIPAS' ></a>");
          client.println("<a href = \"/?lightoff1\"\"><input type = 'button' value = 'OFF KIPAS' ></a> ");
          client.println("<a href = \"/?lighton2\"\"><input type = 'button' value = 'ON KULKAS' ></a>");
          client.println("<a href = \"/?lightoff2\"\"><input type = 'button' value = 'OFF KULKAS' ></a> ");
          client.println("<a href = \"/?lighton3\"\"><input type = 'button' value = 'ON LAMPU TENGAH' ></a>");
          client.println("<a href = \"/?lightoff3\"\"><input type = 'button' value = 'OFF LAMPU TENGAH' ></a> ");
          client.println("<a href = \"/?lighton4\"\"><input type = 'button' value = 'ON LAMPU TERAS' ></a>");
          client.println("<a href = \"/?lightoff4\"\"><input type = 'button' value = 'OFF LAMPU TERAS' ></a> ");
          client.println("<BR>");
          client.println("<BR>");       
          client.println("<h5>");   
          client.println("SET ON KIPAS = ");
          client.println(onkip);
            client.println("<BR>");
          client.println("SET OFF KIPAS = ");
          client.println(offkip);
            client.println("<BR>");
          client.println("SET ON KULKAS = ");
          client.println(onkul);
            client.println("<BR>");
          client.println("SET OFF KULKAS = ");
          client.println(offkul);
            client.println("<BR>");
          client.println("SET ON LAMPU TENGAH = ");
          client.println(onlt);
            client.println("<BR>");
          client.println("SET OFF LAMPU TENGAH =");
          client.println(offlt);
            client.println("<BR>");
          client.println("SET ON LAMPU TERAS = ");
          client.println(onls);
            client.println("<BR>");
          client.println("SET OFF LAMPU TERAS =");
          client.println(offls);
            client.println("<BR>");
           
          client.println("</h5>");
          client.println("<BR>");

          client.println("</BODY>");
          client.println("</HTML>");

          delay(1);
          //stopping client

          client.stop();
        
        
          //==========================================================
         
          if(readString.indexOf("?lighton1") >0)
          { 
            digitalWrite(A0, HIGH);    
          }
         
          if(readString.indexOf("?lightoff1") >0)
          { 
            digitalWrite(A0, LOW);    
          }
         
          if(readString.indexOf("?lighton2") >0)
          { 
            digitalWrite(A1, HIGH);    
          }
         
          if(readString.indexOf("?lightoff2") >0)
          { 
            digitalWrite(A1, LOW);    
          }
         
          if(readString.indexOf("?lighton3") >0)
          { 
            digitalWrite(A2, HIGH);    
          }
         
          if(readString.indexOf("?lightoff3") >0)
          { 
            digitalWrite(A2, LOW);    
          }
         
          if(readString.indexOf("?lighton4") >0)
          { 
            digitalWrite(A3, HIGH);    
          }
         
          if(readString.indexOf("?lightoff4") >0)
          { 
            digitalWrite(A3, LOW);    
          }
        
          //==========================================================
          if(readString.indexOf("A7") >0)//checks for on
          {
             onkip = 7;          
          }
         
             if(readString.indexOf("A8") >0)//checks for on
          {
             onkip = 7;          
          }
         
             if(readString.indexOf("A9") >0)//checks for on
          {
             onkip = 7;          
          }
         
          //============================================================
                 
          if(readString.indexOf("B20") >0)//checks for on
          {
             offkip = 20;
          }
         
            if(readString.indexOf("B21") >0)//checks for on
          {
             offkip = 21;
          }
         
            if(readString.indexOf("B22") >0)//checks for on
          {
             offkip = 22;
          }
        
          //====================================================
         
          if(readString.indexOf("C7") >0)//checks for on
          {
             onkul = 7;
           
          }
         
           if(readString.indexOf("C8") >0)//checks for on
          {
             onkul = 8;
           
          }
         
           if(readString.indexOf("C9") >0)//checks for on
          {
             onkul = 9;
           
          }
         
          //=========================================================
                
          if(readString.indexOf("D20") >0)//checks for off
          {
             offkul = 20;
          }
         
          if(readString.indexOf("D21") >0)//checks for off
          {
             offkul = 21;
          }
         
          if(readString.indexOf("D22") >0)//checks for off
          {
             offkul = 22;
          }
        
          //=========================================================
        
          if(readString.indexOf("E7") >0)//checks for off
          {
            onlt = 7;
          }
         
           if(readString.indexOf("E8") >0)//checks for off
          {
            onlt = 8;
          }
         
           if(readString.indexOf("E9") >0)//checks for off
          {
            onlt = 9;
          }
         
          //==========================================================
         
          if(readString.indexOf("F20") >0)//checks for off
          {
            offlt = 20;
          }
         
          if(readString.indexOf("F21") >0)//checks for off
          {
            offlt = 21;
          }
         
          if(readString.indexOf("F22") >0)//checks for off
          {
            offlt = 22;
          }
         
          //=========================================================
         
          if(readString.indexOf("G7") >0)//checks for off
          {
            onls = 7;
          }
         
           if(readString.indexOf("G8") >0)//checks for off
          {
            onls = 8;
          }
         
           if(readString.indexOf("G9") >0)//checks for off
          {
            onls = 9;
          }
         
          //=========================================================
         
          if(readString.indexOf("H20") >0)//checks for off
          {
            offls = 20;
          }
         
           if(readString.indexOf("H21") >0)//checks for off
          {
            offls = 21;
          }
         
           if(readString.indexOf("H22") >0)//checks for off
          {
            offls = 22;
          }
         
          //==============================================================================
        //   Serial.print(rtc.getDOWStr());
        //   Serial.print(" ");
        //   Serial.print(rtc.getDOWStr(FORMAT_LONG));
        //   Serial.print(" -- ");
        //   Serial.println(rtc.getTimeStr());
 
          if((t.hour == onkip)&&(t.hour > 0)){
          digitalWrite(A0,HIGH);
          }
         
          if((t.hour == offkip)&&(t.hour > 0)){
          digitalWrite(A0,LOW);
          }
         
          if((t.hour == onkul)&&(t.hour > 0)){
          digitalWrite(A1,HIGH);
          }
         
          if((t.hour == offkul)&&(t.hour > 0)){
          digitalWrite(A1,LOW);
          }
         
          if((t.hour == onlt)&&(t.hour > 0)){
          digitalWrite(A2,HIGH);
          }
         
          if((t.hour == offlt)&&(t.hour > 0)){
          digitalWrite(A2,LOW);
          }

          if((t.hour == onls)&&(t.hour > 0)){
          digitalWrite(A3,HIGH);
          }
         
          if((t.hour == offls)&&(t.hour > 0)){
          digitalWrite(A3,LOW);
          }
        
          //clearing string for next read
          readString="";

        }
      }
    }
  }
}





g. Gambar WEB







h. VIDEO HASILNYA