Translate

Membuat Timer Count Down Menggunakan D-Flop Flop dan 7Segment

Membuat Timer Count Down Menggunakan D-Flop Flop dan 7Segment


           Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat timer count down menggunakan rangkaian analog tanpa mikrokontroller, IC yang digunakan yaitu IC D-flip-flop 74LS74 dan IC BCD to 7seg 74LS47. Alat ini counter down dari angka 9 ke angka 0 dengan menggunakan sebuah tombol untuk mengganti angkanya. 7Segment yang dipakai adalah common anoda sehingga harus dikasih tegangan 5 volt untuk mengaktifkannya. untuk lebih jelasnya berikut gambar per komponennya. Untuk download simulasi PROTEUS-nya bisa di link berikut




a. Tombol




b. IC 7474




c. IC 7447




d. 7Segment CA





e. Cara Penggunaan Alat

             Pertama yaitu hubungkan alat dengan power supply 5v dan pastikan ada pengaman tegangan seperti dioda atau sejenisnya, jika berhasil maka akan tampak nilai pada 7segment. tekan tombol secara perlahan sehingga akan tampak jelas angka yang count down atau berhitung mundur dari 9 sampai ke 0. jika sudah 0 maka akan balik lagi ke 9 dan seterusnya begitu.









Mengakses Sensor PH dengan Mikrokontroller, Membuat Alat Deteksi PH Cairan / AIR

Mengakses Sensor PH dengan Mikrokontroller, Membuat Alat Deteksi PH Cairan / AIR


         Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana membuat dan mengakses alat menggunakan sensor PH. jadi fungsi dari alat ini adalah untuk mengetahui tingkat asam dan basa suatu cairan misal susu atau air kolam. aplikasi dari alat ini yaitu bisa untuk intensitas PH kolam lele, pengukur kualitas susu, dan lain-lain. yang perlu diperhatikan yaitu pertama harus memiliki kalibrator terlebih dahulu sejenis cairan dengan PH yang telah diketahui yang kemudian dilakukan linierisasi menggunakan data adc yang terbaca sehingga didapat persamaan rumusnya. untuk lebih jelasnya berikut adalah skema dan programnya.



a. Minimum System




b. Sensor PH ( Probe dan Amplifier )




VCC - 5v
GND - 0v
P0 - Pin ADC



c. Cara Kalibrasi Sensor







c. Program Bascom AVR

$regfile = "m8535.dat"
$crystal = 12000000

Config Lcdpin = Pin , Rs = Portc.0 , E = Portc.1 , Db4 = Portc.2
Config Lcdpin = Pin , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5
Config Lcd = 16 * 2

Config Adc = Single , Prescaler = Auto , Reference = Avcc

Start Adc

Cls
Cursor Off


Dim Dataadc As Word
Dim Ph As Single

Do

Dataadc = Getadc(0)

Ph = -0.021 * Dataadc
Ph = Ph + 19.92

Upperline
Lcd Dataadc

Lowerline
Lcd "PH = " ; Fusing(ph , "#.##")

Waitms 200

Loop




 d. Cara Menggunakan Alat
          
        Pertama yang harus dilakukan yaitu mengukur adc pada kalibrator, jadi siapkan 2 buah kalibrator dengan variasi PH, kemudian setiap kali dicelupkan ke cairan kalibrator harus dinetralkan dengan PH 7 atau dengan AQUADES. kemudian setelah semua data didapat dimasukkan ke dalam grafik sehingga akan didapatkan rumus persamaan PH. Gunakan rumus persamaan tersebut untuk pembuktian, jika berhasil maka Detektor PH siap digunakan.







Jual Kontroller POMPA AIR MANCUR / LAMPU AC / KOLAM ( Water PUMP Controller )

Jual Kontroller POMPA AIR MANCUR / LAMPU AC ( Water PUMP Controller )


            Kami menyediakan jasa pembuatan alat kendali pompa air dan juga menjual aneka kontroller untuk pompa air mancur, jumlah pompa yang dibutuhkan sesuai dengan pesanan dan juga variasi gerakan nyala pompa juga bisa diatur sesuai pesanan, alat ini tidak hanya untuk pompa air macur tetapi bisa digunakan untuk kontroller nyala lampu AC juga bisa, misal untuk disko atau untuk lampu panggung atau lapangan. kami memiliki 2 jenis produk yaitu

Mau pesan bisa WA atau SMS ke nomer
085726496643



1. Kontroller Menggunakan Relay

  Spesifikasi
- Menggunakan Relay Omron 10A
- Maksimal Daya Pompa 220v 10A
- Dapat di program menggunakan Timer
- Terdapat RTC jadi bisa setting jam ON dan OFF nya untuk otomatis
- Supply menggunakan 12v 5A.


 FOTO ALAT






2. Kontroller menggunakan TRIAC dan Optocoupler

  Spesifikasi =
- Menggunakan TRIAC BTA41 40A
- Menggunakan Optocoupler MOC3021
- Maksimal Daya Pompa 220v 40A
- Dapat di program menggunakan Timer
- Terdapat RTC jadi bisa setting jam ON dan OFF nya untuk otomatis
- Supply menggunakan 12v 5A.


FOTO ALAT














3. VIDEO HASILNYA















Membuat kendali led dengan ARDUINO + RTC

Membuat kendali led dengan ARDUINO + RTC


           Kali ini akan saya bahas mengenai bagaimana cara membuat alat untuk kendali lampu lalu lintas yang disimulasikan dengan led, disini dilengkapi dengan jam dan juga hari yang tampil di layar LCD, alat ini dilengkapi 3 buah tombol yang mana tiap tombol mewakili satu buah instruksi yang mengandung rule jam ON dan OFF led, jadi misal tombol 1 ditekan, led akan hidup hari senin sampai kamis jam 8.00 sampai jam 13.00, tombol 2 untuk hari jumat-sabtu jam 8.00 - 13.00 begitu pula dengan tombol 3. untuk lebih jelasnya berikut program dan skemanya.



a. Arduino Mega




b. LCD 16x2




c. RTC DS1307




d. LED + PUSH BUTTON





e. Program Arduino IDE

#include <LiquidCrystal.h>
#include "Wire.h"
 #define DS3231_I2C_ADDRESS 0x68

// Convert normal decimal numbers to binary coded decimal
LiquidCrystal lcd(8, 7, 6, 3, 4, 5);


byte decToBcd(byte val)
{
  return( (val/10*16) + (val%10) );
}
// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
  return( (val/16*10) + (val%16) );
}

int led1 = A0;
int led2 = A1;
int led3 = A2;

int led4 = A3;
int led5 = A4;
int led6 = A5;

int led7 = A6;
int led8 = A7;
int led9 = A8;

int led10 = A9;
int led11 = A10;
int led12 = A11;

int mark = 0;

const int buttonPin1 = 14;
const int buttonPin2 = 15;
const int buttonPin3 = 16;
int buttonState1 = 0;
int buttonState2 = 0;
int buttonState3 = 0;



void setup() {
 
  // DS3231 seconds, minutes, hours, day, date, month, year
//setDS3231time(0,4,9,2,23,5,16);
  Wire.begin();
  lcd.begin(16, 2);
  lcd.clear();
  lcd.noCursor();

pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
pinMode(led7, OUTPUT);
pinMode(led8, OUTPUT);
pinMode(led9, OUTPUT);
pinMode(led10, OUTPUT);
pinMode(led11, OUTPUT);
pinMode(led12, OUTPUT);

pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);

}



void setDS3231time(byte second, byte minute, byte hour, byte dayOfWeek, byte dayOfMonth, byte month, byte year)
{
  // sets time and date data to DS3231
  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(0); // set next input to start at the seconds register
  Wire.write(decToBcd(second)); // set seconds
  Wire.write(decToBcd(minute)); // set minutes
  Wire.write(decToBcd(hour)); // set hours
  Wire.write(decToBcd(dayOfWeek)); // set day of week (1=Sunday, 7=Saturday)
  Wire.write(decToBcd(dayOfMonth)); // set date (1 to 31)
  Wire.write(decToBcd(month)); // set month
  Wire.write(decToBcd(year)); // set year (0 to 99)
  Wire.endTransmission();
}
void readDS3231time(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(0); // set DS3231 register pointer to 00h
  Wire.endTransmission();
  Wire.requestFrom(DS3231_I2C_ADDRESS, 7);
  // request seven bytes of data from DS3231 starting from register 00h
  *second = bcdToDec(Wire.read() & 0x7f);
  *minute = bcdToDec(Wire.read());
  *hour = bcdToDec(Wire.read() & 0x3f);
  *dayOfWeek = bcdToDec(Wire.read());
  *dayOfMonth = bcdToDec(Wire.read());
  *month = bcdToDec(Wire.read());
  *year = bcdToDec(Wire.read());
}


void displayTime1()
{
  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  // retrieve data from DS3231
  readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
  // send it to the serial monitor
  lcd.setCursor(0, 0);
  lcd.print(hour, DEC);
  // convert the byte variable to a decimal number when displayed
  lcd.print(":");
  if (minute<10)
  {
    lcd.print("0");
  }
  lcd.print(minute, DEC);
  lcd.print(":");
  if (second<10)
  {
    lcd.print("0");
  }
  lcd.print(second, DEC);

  lcd.setCursor(0, 1);
  lcd.print(dayOfMonth, DEC);
  lcd.print("/");
  lcd.print(month, DEC);
  lcd.print("/");
  lcd.print(year, DEC);
 
  switch(dayOfWeek){
    lcd.setCursor(13, 1);   
  case 1:  
    lcd.print("  MInggu");
    break;
  case 2:
    lcd.print("  Senin");
    break;
  case 3:
    lcd.print("  Selasa");
    break;
  case 4:
    lcd.print("  Rabu");
    break;
  case 5:
    lcd.print("  Kamis");
    break;
  case 6:
    lcd.print("  Jum'at");
    break;
  case 7:
    lcd.print("  Sabtu");
    break;
  }
 
 
 
 
if ((hour >= 5) && (hour <= 8) && (dayOfWeek >= 2) && (dayOfWeek <= 5)){
digitalWrite(led1, HIGH);
digitalWrite(led4, HIGH);
digitalWrite(led7, HIGH);
digitalWrite(led10, HIGH);
delay(1000);

  digitalWrite(led1, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
delay(1000);

  digitalWrite(led1, LOW); 
  digitalWrite(led2, HIGH);
  digitalWrite(led3, LOW);
delay(1000);

  digitalWrite(led1, LOW); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, HIGH);
delay(1000);

  digitalWrite(led1, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);


//=========================================================

  digitalWrite(led4, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, LOW);
delay(1000);

  digitalWrite(led4, LOW);
  digitalWrite(led5, HIGH); 
  digitalWrite(led6, LOW);
delay(1000);

  digitalWrite(led4, LOW);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, HIGH);
delay(1000);

  digitalWrite(led4, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, LOW);



//========================================================

  digitalWrite(led7, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led9, LOW);
delay(1000);

  digitalWrite(led7, LOW);
  digitalWrite(led8, HIGH);
  digitalWrite(led9, LOW);
delay(1000);

  digitalWrite(led7, LOW);
  digitalWrite(led8, LOW);
  digitalWrite(led9, HIGH);
delay(1000);

  digitalWrite(led7, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led9, LOW);


//========================================================

  digitalWrite(led10, HIGH);
  digitalWrite(led11, LOW);
  digitalWrite(led12, LOW);
delay(1000);

  digitalWrite(led10, LOW);
  digitalWrite(led11, HIGH);
  digitalWrite(led12, LOW);
delay(1000);

  digitalWrite(led10, LOW);
  digitalWrite(led11, LOW);
  digitalWrite(led12, HIGH);
delay(1000);

  digitalWrite(led10, HIGH);
  digitalWrite(led11, LOW);
  digitalWrite(led12, LOW);
}


if ((hour >= 11) && (hour <= 13) && (dayOfWeek >= 2) && (dayOfWeek <= 5)){
digitalWrite(led1, HIGH);
digitalWrite(led4, HIGH);
digitalWrite(led7, HIGH);
digitalWrite(led10, HIGH);
delay(1000);

  digitalWrite(led1, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
delay(1000);

  digitalWrite(led1, LOW); 
  digitalWrite(led2, HIGH);
  digitalWrite(led3, LOW);
delay(1000);

  digitalWrite(led1, LOW); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, HIGH);
delay(1000);

  digitalWrite(led1, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);


//=========================================================

  digitalWrite(led4, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, LOW);
delay(1000);

  digitalWrite(led4, LOW);
  digitalWrite(led5, HIGH); 
  digitalWrite(led6, LOW);
delay(1000);

  digitalWrite(led4, LOW);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, HIGH);
delay(1000);

  digitalWrite(led4, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, LOW);



//========================================================

  digitalWrite(led7, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led9, LOW);
delay(1000);

  digitalWrite(led7, LOW);
  digitalWrite(led8, HIGH);
  digitalWrite(led9, LOW);
delay(1000);

  digitalWrite(led7, LOW);
  digitalWrite(led8, LOW);
  digitalWrite(led9, HIGH);
delay(1000);

  digitalWrite(led7, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led9, LOW);


//========================================================

  digitalWrite(led10, HIGH);
  digitalWrite(led11, LOW);
  digitalWrite(led12, LOW);
delay(1000);

  digitalWrite(led10, LOW);
  digitalWrite(led11, HIGH);
  digitalWrite(led12, LOW);
delay(1000);

  digitalWrite(led10, LOW);
  digitalWrite(led11, LOW);
  digitalWrite(led12, HIGH);
delay(1000);

  digitalWrite(led10, HIGH);
  digitalWrite(led11, LOW);
  digitalWrite(led12, LOW);
}



if ((hour >= 17) && (hour <= 18) && (dayOfWeek >= 2) && (dayOfWeek <= 5)){
digitalWrite(led1, HIGH);
digitalWrite(led4, HIGH);
digitalWrite(led7, HIGH);
digitalWrite(led10, HIGH);
delay(1000);

  digitalWrite(led1, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
delay(1000);

  digitalWrite(led1, LOW); 
  digitalWrite(led2, HIGH);
  digitalWrite(led3, LOW);
delay(1000);

  digitalWrite(led1, LOW); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, HIGH);
delay(1000);

  digitalWrite(led1, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);


//=========================================================

  digitalWrite(led4, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, LOW);
delay(1000);

  digitalWrite(led4, LOW);
  digitalWrite(led5, HIGH); 
  digitalWrite(led6, LOW);
delay(1000);

  digitalWrite(led4, LOW);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, HIGH);
delay(1000);

  digitalWrite(led4, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, LOW);



//========================================================

  digitalWrite(led7, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led9, LOW);
delay(1000);

  digitalWrite(led7, LOW);
  digitalWrite(led8, HIGH);
  digitalWrite(led9, LOW);
delay(1000);

  digitalWrite(led7, LOW);
  digitalWrite(led8, LOW);
  digitalWrite(led9, HIGH);
delay(1000);

  digitalWrite(led7, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led9, LOW);


//========================================================

  digitalWrite(led10, HIGH);
  digitalWrite(led11, LOW);
  digitalWrite(led12, LOW);
delay(1000);

  digitalWrite(led10, LOW);
  digitalWrite(led11, HIGH);
  digitalWrite(led12, LOW);
delay(1000);

  digitalWrite(led10, LOW);
  digitalWrite(led11, LOW);
  digitalWrite(led12, HIGH);
delay(1000);

  digitalWrite(led10, HIGH);
  digitalWrite(led11, LOW);
  digitalWrite(led12, LOW);
}

else {

  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
  digitalWrite(led4, LOW);
  digitalWrite(led5, LOW);
  digitalWrite(led6, LOW);
  digitalWrite(led7, LOW);
  digitalWrite(led8, LOW);
  digitalWrite(led9, LOW);
  digitalWrite(led10, LOW);
  digitalWrite(led11, LOW);
  digitalWrite(led12, LOW);

}


}



void displayTime2()
{
  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  // retrieve data from DS3231
  readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
  // send it to the serial monitor
  lcd.setCursor(0, 0);
  lcd.print(hour, DEC);
  // convert the byte variable to a decimal number when displayed
  lcd.print(":");
  if (minute<10)
  {
    lcd.print("0");
  }
  lcd.print(minute, DEC);
  lcd.print(":");
  if (second<10)
  {
    lcd.print("0");
  }
  lcd.print(second, DEC);

  lcd.setCursor(0, 1);
  lcd.print(dayOfMonth, DEC);
  lcd.print("/");
  lcd.print(month, DEC);
  lcd.print("/");
  lcd.print(year, DEC);
 
  switch(dayOfWeek){
    lcd.setCursor(13, 1);   
  case 1:  
    lcd.print("  MInggu");
    break;
  case 2:
    lcd.print("  Senin");
    break;
  case 3:
    lcd.print("  Selasa");
    break;
  case 4:
    lcd.print("  Rabu");
    break;
  case 5:
    lcd.print("  Kamis");
    break;
  case 6:
    lcd.print("  Jum'at");
    break;
  case 7:
    lcd.print("  Sabtu");
    break;
  }
 
if ((hour >= 5) && (hour <= 8) && (dayOfWeek >= 6) && (dayOfWeek <= 7)){
digitalWrite(led1, HIGH);
digitalWrite(led4, HIGH);
digitalWrite(led7, HIGH);
digitalWrite(led10, HIGH);
delay(1000);

  digitalWrite(led1, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
delay(1000);

  digitalWrite(led1, LOW); 
  digitalWrite(led2, HIGH);
  digitalWrite(led3, LOW);
delay(1000);

  digitalWrite(led1, LOW); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, HIGH);
delay(1000);

  digitalWrite(led1, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);


//=========================================================

  digitalWrite(led4, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, LOW);
delay(1000);

  digitalWrite(led4, LOW);
  digitalWrite(led5, HIGH); 
  digitalWrite(led6, LOW);
delay(1000);

  digitalWrite(led4, LOW);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, HIGH);
delay(1000);

  digitalWrite(led4, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, LOW);



//========================================================

  digitalWrite(led7, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led9, LOW);
delay(1000);

  digitalWrite(led7, LOW);
  digitalWrite(led8, HIGH);
  digitalWrite(led9, LOW);
delay(1000);

  digitalWrite(led7, LOW);
  digitalWrite(led8, LOW);
  digitalWrite(led9, HIGH);
delay(1000);

  digitalWrite(led7, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led9, LOW);


//========================================================

  digitalWrite(led10, HIGH);
  digitalWrite(led11, LOW);
  digitalWrite(led12, LOW);
delay(1000);

  digitalWrite(led10, LOW);
  digitalWrite(led11, HIGH);
  digitalWrite(led12, LOW);
delay(1000);

  digitalWrite(led10, LOW);
  digitalWrite(led11, LOW);
  digitalWrite(led12, HIGH);
delay(1000);

  digitalWrite(led10, HIGH);
  digitalWrite(led11, LOW);
  digitalWrite(led12, LOW);
}


if ((hour >= 11) && (hour <= 13) && (dayOfWeek >= 6) && (dayOfWeek <= 7)){
digitalWrite(led1, HIGH);
digitalWrite(led4, HIGH);
digitalWrite(led7, HIGH);
digitalWrite(led10, HIGH);
delay(1000);

  digitalWrite(led1, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
delay(1000);

  digitalWrite(led1, LOW); 
  digitalWrite(led2, HIGH);
  digitalWrite(led3, LOW);
delay(1000);

  digitalWrite(led1, LOW); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, HIGH);
delay(1000);

  digitalWrite(led1, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);


//=========================================================

  digitalWrite(led4, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, LOW);
delay(1000);

  digitalWrite(led4, LOW);
  digitalWrite(led5, HIGH); 
  digitalWrite(led6, LOW);
delay(1000);

  digitalWrite(led4, LOW);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, HIGH);
delay(1000);

  digitalWrite(led4, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, LOW);



//========================================================

  digitalWrite(led7, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led9, LOW);
delay(1000);

  digitalWrite(led7, LOW);
  digitalWrite(led8, HIGH);
  digitalWrite(led9, LOW);
delay(1000);

  digitalWrite(led7, LOW);
  digitalWrite(led8, LOW);
  digitalWrite(led9, HIGH);
delay(1000);

  digitalWrite(led7, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led9, LOW);


//========================================================

  digitalWrite(led10, HIGH);
  digitalWrite(led11, LOW);
  digitalWrite(led12, LOW);
delay(1000);

  digitalWrite(led10, LOW);
  digitalWrite(led11, HIGH);
  digitalWrite(led12, LOW);
delay(1000);

  digitalWrite(led10, LOW);
  digitalWrite(led11, LOW);
  digitalWrite(led12, HIGH);
delay(1000);

  digitalWrite(led10, HIGH);
  digitalWrite(led11, LOW);
  digitalWrite(led12, LOW);
}



if ((hour >= 17) && (hour <= 18) && (dayOfWeek >= 6) && (dayOfWeek <= 7)){
digitalWrite(led1, HIGH);
digitalWrite(led4, HIGH);
digitalWrite(led7, HIGH);
digitalWrite(led10, HIGH);
delay(1000);

  digitalWrite(led1, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
delay(1000);

  digitalWrite(led1, LOW); 
  digitalWrite(led2, HIGH);
  digitalWrite(led3, LOW);
delay(1000);

  digitalWrite(led1, LOW); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, HIGH);
delay(1000);

  digitalWrite(led1, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);


//=========================================================

  digitalWrite(led4, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, LOW);
delay(1000);

  digitalWrite(led4, LOW);
  digitalWrite(led5, HIGH); 
  digitalWrite(led6, LOW);
delay(1000);

  digitalWrite(led4, LOW);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, HIGH);
delay(1000);

  digitalWrite(led4, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, LOW);



//========================================================

  digitalWrite(led7, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led9, LOW);
delay(1000);

  digitalWrite(led7, LOW);
  digitalWrite(led8, HIGH);
  digitalWrite(led9, LOW);
delay(1000);

  digitalWrite(led7, LOW);
  digitalWrite(led8, LOW);
  digitalWrite(led9, HIGH);
delay(1000);

  digitalWrite(led7, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led9, LOW);


//========================================================

  digitalWrite(led10, HIGH);
  digitalWrite(led11, LOW);
  digitalWrite(led12, LOW);
delay(1000);

  digitalWrite(led10, LOW);
  digitalWrite(led11, HIGH);
  digitalWrite(led12, LOW);
delay(1000);

  digitalWrite(led10, LOW);
  digitalWrite(led11, LOW);
  digitalWrite(led12, HIGH);
delay(1000);

  digitalWrite(led10, HIGH);
  digitalWrite(led11, LOW);
  digitalWrite(led12, LOW);
}

else {

  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
  digitalWrite(led4, LOW);
  digitalWrite(led5, LOW);
  digitalWrite(led6, LOW);
  digitalWrite(led7, LOW);
  digitalWrite(led8, LOW);
  digitalWrite(led9, LOW);
  digitalWrite(led10, LOW);
  digitalWrite(led11, LOW);
  digitalWrite(led12, LOW);

}

}





void displayTime3()
{
  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  // retrieve data from DS3231
  readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
  // send it to the serial monitor
  lcd.setCursor(0, 0);
  lcd.print(hour, DEC);
  // convert the byte variable to a decimal number when displayed
  lcd.print(":");
  if (minute<10)
  {
    lcd.print("0");
  }
  lcd.print(minute, DEC);
  lcd.print(":");
  if (second<10)
  {
    lcd.print("0");
  }
  lcd.print(second, DEC);

  lcd.setCursor(0, 1);
  lcd.print(dayOfMonth, DEC);
  lcd.print("/");
  lcd.print(month, DEC);
  lcd.print("/");
  lcd.print(year, DEC);
 
  switch(dayOfWeek){
    lcd.setCursor(13, 1);   
  case 1:  
    lcd.print("  MInggu");
    break;
  case 2:
    lcd.print("  Senin");
    break;
  case 3:
    lcd.print("  Selasa");
    break;
  case 4:
    lcd.print("  Rabu");
    break;
  case 5:
    lcd.print("  Kamis");
    break;
  case 6:
    lcd.print("  Jum'at");
    break;
  case 7:
    lcd.print("  Sabtu");
    break;
  }

if ((hour >= 5) && (hour <= 8) && (dayOfWeek ==1) ){
digitalWrite(led1, HIGH);
digitalWrite(led4, HIGH);
digitalWrite(led7, HIGH);
digitalWrite(led10, HIGH);
delay(1000);

  digitalWrite(led1, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
delay(1000);

  digitalWrite(led1, LOW); 
  digitalWrite(led2, HIGH);
  digitalWrite(led3, LOW);
delay(1000);

  digitalWrite(led1, LOW); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, HIGH);
delay(1000);

  digitalWrite(led1, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);


//=========================================================

  digitalWrite(led4, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, LOW);
delay(1000);

  digitalWrite(led4, LOW);
  digitalWrite(led5, HIGH); 
  digitalWrite(led6, LOW);
delay(1000);

  digitalWrite(led4, LOW);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, HIGH);
delay(1000);

  digitalWrite(led4, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, LOW);



//========================================================

  digitalWrite(led7, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led9, LOW);
delay(1000);

  digitalWrite(led7, LOW);
  digitalWrite(led8, HIGH);
  digitalWrite(led9, LOW);
delay(1000);

  digitalWrite(led7, LOW);
  digitalWrite(led8, LOW);
  digitalWrite(led9, HIGH);
delay(1000);

  digitalWrite(led7, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led9, LOW);


//========================================================

  digitalWrite(led10, HIGH);
  digitalWrite(led11, LOW);
  digitalWrite(led12, LOW);
delay(1000);

  digitalWrite(led10, LOW);
  digitalWrite(led11, HIGH);
  digitalWrite(led12, LOW);
delay(1000);

  digitalWrite(led10, LOW);
  digitalWrite(led11, LOW);
  digitalWrite(led12, HIGH);
delay(1000);

  digitalWrite(led10, HIGH);
  digitalWrite(led11, LOW);
  digitalWrite(led12, LOW);
}


if ((hour >= 12) && (hour <= 2) && (dayOfWeek ==1) ){
digitalWrite(led1, HIGH);
digitalWrite(led4, HIGH);
digitalWrite(led7, HIGH);
digitalWrite(led10, HIGH);
delay(1000);

  digitalWrite(led1, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
delay(1000);

  digitalWrite(led1, LOW); 
  digitalWrite(led2, HIGH);
  digitalWrite(led3, LOW);
delay(1000);

  digitalWrite(led1, LOW); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, HIGH);
delay(1000);

  digitalWrite(led1, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);


//=========================================================

  digitalWrite(led4, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, LOW);
delay(1000);

  digitalWrite(led4, LOW);
  digitalWrite(led5, HIGH); 
  digitalWrite(led6, LOW);
delay(1000);

  digitalWrite(led4, LOW);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, HIGH);
delay(1000);

  digitalWrite(led4, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, LOW);



//========================================================

  digitalWrite(led7, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led9, LOW);
delay(1000);

  digitalWrite(led7, LOW);
  digitalWrite(led8, HIGH);
  digitalWrite(led9, LOW);
delay(1000);

  digitalWrite(led7, LOW);
  digitalWrite(led8, LOW);
  digitalWrite(led9, HIGH);
delay(1000);

  digitalWrite(led7, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led9, LOW);


//========================================================

  digitalWrite(led10, HIGH);
  digitalWrite(led11, LOW);
  digitalWrite(led12, LOW);
delay(1000);

  digitalWrite(led10, LOW);
  digitalWrite(led11, HIGH);
  digitalWrite(led12, LOW);
delay(1000);

  digitalWrite(led10, LOW);
  digitalWrite(led11, LOW);
  digitalWrite(led12, HIGH);
delay(1000);

  digitalWrite(led10, HIGH);
  digitalWrite(led11, LOW);
  digitalWrite(led12, LOW);
}



if ((hour >= 17) && (hour <= 19) && (dayOfWeek ==1) ){
digitalWrite(led1, HIGH);
digitalWrite(led4, HIGH);
digitalWrite(led7, HIGH);
digitalWrite(led10, HIGH);
delay(1000);

  digitalWrite(led1, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
delay(1000);

  digitalWrite(led1, LOW); 
  digitalWrite(led2, HIGH);
  digitalWrite(led3, LOW);
delay(1000);

  digitalWrite(led1, LOW); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, HIGH);
delay(1000);

  digitalWrite(led1, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);


//=========================================================

  digitalWrite(led4, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, LOW);
delay(1000);

  digitalWrite(led4, LOW);
  digitalWrite(led5, HIGH); 
  digitalWrite(led6, LOW);
delay(1000);

  digitalWrite(led4, LOW);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, HIGH);
delay(1000);

  digitalWrite(led4, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, LOW);



//========================================================

  digitalWrite(led7, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led9, LOW);
delay(1000);

  digitalWrite(led7, LOW);
  digitalWrite(led8, HIGH);
  digitalWrite(led9, LOW);
delay(1000);

  digitalWrite(led7, LOW);
  digitalWrite(led8, LOW);
  digitalWrite(led9, HIGH);
delay(1000);

  digitalWrite(led7, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led9, LOW);


//========================================================

  digitalWrite(led10, HIGH);
  digitalWrite(led11, LOW);
  digitalWrite(led12, LOW);
delay(1000);

  digitalWrite(led10, LOW);
  digitalWrite(led11, HIGH);
  digitalWrite(led12, LOW);
delay(1000);

  digitalWrite(led10, LOW);
  digitalWrite(led11, LOW);
  digitalWrite(led12, HIGH);
delay(1000);

  digitalWrite(led10, HIGH);
  digitalWrite(led11, LOW);
  digitalWrite(led12, LOW);
}



if ((hour >= 21) && (dayOfWeek ==1) ){
digitalWrite(led1, HIGH);
digitalWrite(led4, HIGH);
digitalWrite(led7, HIGH);
digitalWrite(led10, HIGH);
delay(1000);

  digitalWrite(led1, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
delay(1000);

  digitalWrite(led1, LOW); 
  digitalWrite(led2, HIGH);
  digitalWrite(led3, LOW);
delay(1000);

  digitalWrite(led1, LOW); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, HIGH);
delay(1000);

  digitalWrite(led1, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);


//=========================================================

  digitalWrite(led4, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, LOW);
delay(1000);

  digitalWrite(led4, LOW);
  digitalWrite(led5, HIGH); 
  digitalWrite(led6, LOW);
delay(1000);

  digitalWrite(led4, LOW);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, HIGH);
delay(1000);

  digitalWrite(led4, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, LOW);



//========================================================

  digitalWrite(led7, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led9, LOW);
delay(1000);

  digitalWrite(led7, LOW);
  digitalWrite(led8, HIGH);
  digitalWrite(led9, LOW);
delay(1000);

  digitalWrite(led7, LOW);
  digitalWrite(led8, LOW);
  digitalWrite(led9, HIGH);
delay(1000);

  digitalWrite(led7, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led9, LOW);


//========================================================

  digitalWrite(led10, HIGH);
  digitalWrite(led11, LOW);
  digitalWrite(led12, LOW);
delay(1000);

  digitalWrite(led10, LOW);
  digitalWrite(led11, HIGH);
  digitalWrite(led12, LOW);
delay(1000);

  digitalWrite(led10, LOW);
  digitalWrite(led11, LOW);
  digitalWrite(led12, HIGH);
delay(1000);

  digitalWrite(led10, HIGH);
  digitalWrite(led11, LOW);
  digitalWrite(led12, LOW);
}


if ((hour >= 0) && (hour <= 2) && (dayOfWeek ==1) ){
digitalWrite(led1, HIGH);
digitalWrite(led4, HIGH);
digitalWrite(led7, HIGH);
digitalWrite(led10, HIGH);
delay(1000);

  digitalWrite(led1, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
delay(1000);

  digitalWrite(led1, LOW); 
  digitalWrite(led2, HIGH);
  digitalWrite(led3, LOW);
delay(1000);

  digitalWrite(led1, LOW); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, HIGH);
delay(1000);

  digitalWrite(led1, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);


//=========================================================

  digitalWrite(led4, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, LOW);
delay(1000);

  digitalWrite(led4, LOW);
  digitalWrite(led5, HIGH); 
  digitalWrite(led6, LOW);
delay(1000);

  digitalWrite(led4, LOW);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, HIGH);
delay(1000);

  digitalWrite(led4, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led6, LOW);



//========================================================

  digitalWrite(led7, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led9, LOW);
delay(1000);

  digitalWrite(led7, LOW);
  digitalWrite(led8, HIGH);
  digitalWrite(led9, LOW);
delay(1000);

  digitalWrite(led7, LOW);
  digitalWrite(led8, LOW);
  digitalWrite(led9, HIGH);
delay(1000);

  digitalWrite(led7, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led9, LOW);


//========================================================

  digitalWrite(led10, HIGH);
  digitalWrite(led11, LOW);
  digitalWrite(led12, LOW);
delay(1000);

  digitalWrite(led10, LOW);
  digitalWrite(led11, HIGH);
  digitalWrite(led12, LOW);
delay(1000);

  digitalWrite(led10, LOW);
  digitalWrite(led11, LOW);
  digitalWrite(led12, HIGH);
delay(1000);

  digitalWrite(led10, HIGH);
  digitalWrite(led11, LOW);
  digitalWrite(led12, LOW);
}


else {

  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
  digitalWrite(led4, LOW);
  digitalWrite(led5, LOW);
  digitalWrite(led6, LOW);
  digitalWrite(led7, LOW);
  digitalWrite(led8, LOW);
  digitalWrite(led9, LOW);
  digitalWrite(led10, LOW);
  digitalWrite(led11, LOW);
  digitalWrite(led12, LOW);

}

}


void loop() {
 
  lcd.setCursor(0, 0);
  lcd.print("PILIH MENU");
  lcd.setCursor(0, 1);
  lcd.print("1     2     3");
 
buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);
buttonState3 = digitalRead(buttonPin3);

while (buttonState1 == LOW) {
lcd.setCursor(8, 0);
lcd.print("  MENU 1");
displayTime1();
}

while (buttonState2 == LOW) {
lcd.setCursor(8, 0);
lcd.print("  MENU 2");
displayTime2();
}

while (buttonState3 == LOW) {
lcd.setCursor(8, 0);
lcd.print("  MENU 3");
displayTime3();
}

}





f. VIDEO HASILNYA











Membuat alat kendali Traffic Light / LED Menggunakan ARDUINO Ethernet WEB SERVER dan RTC

Membuat alat kendali Traffic Light / LED Menggunakan ARDUINO Ethernet WEB SERVER dan RTC


         Pada pagi hari ini saya akan menjelaskan mengenai bagaimana cara membuat alat yang digunakan untuk kendali traffic light LED menggunakan WIFI Ethernet Web Server. Disini saya akan membuat sebuah sistem lampu lalu lintas yang mana delay lampu diset melalui server dan juga waktu nyala dan padam lampu juga diset melalui server, sehingga pada server akan tampil nilai jam dan delay lampu yang diset dan juga pada server terdapat tombol pemilihan untuk setting ulang nilainya. Untuk lebih jelas berikut adalah sema dan programnya.



a. Arduino Mega + LCD 16x2





b. Router




c. Ethernet Shield




d. RTC dan LED


Arduino Mega
SDA - Pin 20
SCL - Pin 21




e. Program Arduino IDE

#include <SPI.h>
#include <Ethernet.h>
#include <LiquidCrystal.h>
#include <Wire.h>
LiquidCrystal lcd(16, 17, 22, 24, 19, 18);


#define DS3231_I2C_ADDRESS 0x68
// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
{
  return( (val/10*16) + (val%10) );
}
// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
  return( (val/16*10) + (val%16) );
}



int led1 = A7;
int led2 = A8;
int led3 = A9;
int led4 = A10;
int led5 = A11;
int led6 = A12;
int led7 = A13;
int led8 = A14;
int led9 = A15;

int dmerah = 0;
int dkuning = 0;
int dhijau = 0;
int ton = 0;
int toff = 0;

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

String readString;


void setup(){
 
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
pinMode(led7, OUTPUT);
pinMode(led8, OUTPUT);
pinMode(led9, OUTPUT);

  lcd.begin(16, 2);
  lcd.clear();
  lcd.noCursor();
  Wire.begin();
 
  // DS3231 seconds, minutes, hours, day, date, month, year
  //setDS3231time(0,59,11,2,16,5,16);
 
  pinMode(13, OUTPUT); //pin selected to control
  //start Ethernet
  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 setDS3231time(byte second, byte minute, byte hour, byte dayOfWeek, byte dayOfMonth, byte month, byte year)
{
  // sets time and date data to DS3231
  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(0); // set next input to start at the seconds register
  Wire.write(decToBcd(second)); // set seconds
  Wire.write(decToBcd(minute)); // set minutes
  Wire.write(decToBcd(hour)); // set hours
  Wire.write(decToBcd(dayOfWeek)); // set day of week (1=Sunday, 7=Saturday)
  Wire.write(decToBcd(dayOfMonth)); // set date (1 to 31)
  Wire.write(decToBcd(month)); // set month
  Wire.write(decToBcd(year)); // set year (0 to 99)
  Wire.endTransmission();
}
void readDS3231time(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(0); // set DS3231 register pointer to 00h
  Wire.endTransmission();
  Wire.requestFrom(DS3231_I2C_ADDRESS, 7);
  // request seven bytes of data from DS3231 starting from register 00h
  *second = bcdToDec(Wire.read() & 0x7f);
  *minute = bcdToDec(Wire.read());
  *hour = bcdToDec(Wire.read() & 0x3f);
  *dayOfWeek = bcdToDec(Wire.read());
  *dayOfMonth = bcdToDec(Wire.read());
  *month = bcdToDec(Wire.read());
  *year = bcdToDec(Wire.read());
}



void displayTime()
{
  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  // retrieve data from DS3231
  readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
  // send it to the serial monitor
  lcd.setCursor(0, 0);
  lcd.print(hour, DEC);
  // convert the byte variable to a decimal number when displayed
  lcd.print(":");
  if (minute<10)
  {
    lcd.print("0");
  }
  lcd.print(minute, DEC);
  lcd.print(":");
  if (second<10)
  {
    lcd.print("0");
  }
  lcd.print(second, DEC);

  lcd.setCursor(0, 1);
  lcd.print(dayOfMonth, DEC);
  lcd.print("/");
  lcd.print(month, DEC);
  lcd.print("/");
  lcd.print(year, DEC);
 
 
   if (hour >= ton) {

  if (hour >= toff) {
  digitalWrite(led3, LOW); 
  digitalWrite(led2, LOW);
  digitalWrite(led1, LOW);

  digitalWrite(led6, LOW);
  digitalWrite(led5, LOW); 
  digitalWrite(led4, LOW);
 
  digitalWrite(led9, LOW);
  digitalWrite(led8, LOW);
  digitalWrite(led7, LOW);
  }
 else {

  digitalWrite(led3, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led1, LOW);

  digitalWrite(led6, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led4, LOW);
 
  digitalWrite(led9, LOW);
  digitalWrite(led8, LOW);
  digitalWrite(led7, HIGH);
  delay(dhijau);

  digitalWrite(led3, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led1, LOW);

  digitalWrite(led6, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led4, LOW);
 
  digitalWrite(led9, LOW);
  digitalWrite(led8, HIGH);
  digitalWrite(led7, LOW);
  delay(dkuning);

  digitalWrite(led3, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led1, LOW);

  digitalWrite(led6, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led4, LOW);
 
  digitalWrite(led9, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led7, LOW);
  delay(dmerah);
 
 
  //==============================
 
  digitalWrite(led3, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led1, LOW);

  digitalWrite(led6, LOW);
  digitalWrite(led5, LOW); 
  digitalWrite(led4, HIGH);
 
  digitalWrite(led9, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led7, LOW);
  delay(dhijau);

  digitalWrite(led3, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led1, LOW);

  digitalWrite(led6, LOW);
  digitalWrite(led5, HIGH); 
  digitalWrite(led4, LOW);
 
  digitalWrite(led9, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led7, LOW);
  delay(dkuning);

  digitalWrite(led3, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led1, LOW);

  digitalWrite(led6, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led4, LOW);
 
  digitalWrite(led9, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led7, LOW);
  delay(dmerah);
 
 
 //=====================================

  digitalWrite(led3, LOW); 
  digitalWrite(led2, LOW);
  digitalWrite(led1, HIGH);

  digitalWrite(led6, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led4, LOW);
 
  digitalWrite(led9, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led7, LOW);
  delay(dhijau);

  digitalWrite(led3, LOW); 
  digitalWrite(led2, HIGH);
  digitalWrite(led1, LOW);

  digitalWrite(led6, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led4, LOW);
 
  digitalWrite(led9, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led7, LOW);
  delay(dkuning);

  digitalWrite(led3, HIGH); 
  digitalWrite(led2, LOW);
  digitalWrite(led1, LOW);

  digitalWrite(led6, HIGH);
  digitalWrite(led5, LOW); 
  digitalWrite(led4, LOW);
 
  digitalWrite(led9, HIGH);
  digitalWrite(led8, LOW);
  digitalWrite(led7, LOW);
  delay(dmerah);
  }

  }
 

 
 
 
}
 



void loop(){
   lcd.setCursor(0, 0);
   lcd.print("SET DELAY LAMPU");
   lcd.setCursor(0, 1);
   lcd.print("SET ON/OFF LAMPU");
 
  digitalWrite(led1, HIGH);  
  digitalWrite(led2, HIGH);
  digitalWrite(led3, HIGH);
  digitalWrite(led4, HIGH);
  digitalWrite(led5, HIGH); 
  digitalWrite(led6, HIGH);
  digitalWrite(led7, HIGH);
  digitalWrite(led8, HIGH);
  digitalWrite(led9, HIGH);



  // 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();

          client.println("<HTML>");
          client.println("<HEAD>");
          client.println("<TITLE>Arduino GET test page</TITLE>");
          client.println("</HEAD>");
          client.println("<BODY>");

          client.println("<H3>kontrol ON / OFF dan delay lampu</H3>");

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

          client.println("Delay Lampu Merah : <INPUT TYPE=TEXT NAME=\"Merah\" VALUE=\"A\" SIZE=\"25\" MAXLENGTH=\"50\"><BR><BR><BR>");
          client.println("Delay Lampu Kuning: <INPUT TYPE=TEXT NAME=\"Kuning\" VALUE=\"B\" SIZE=\"25\" MAXLENGTH=\"50\"><BR><BR><BR>");
          client.println("Delay Lampu Hijau : <INPUT TYPE=TEXT NAME=\"Hijau\" VALUE=\"C\" SIZE=\"25\" MAXLENGTH=\"50\"><BR><BR><BR>");
  
          client.println("Jam ON : <INPUT TYPE=TEXT NAME=\"LEDON\" VALUE=\"D\" SIZE=\"25\" MAXLENGTH=\"50\"><BR><BR><BR>");
          client.println("Jam OFF : <INPUT TYPE=TEXT NAME=\"LEDOFF\" VALUE=\"E\" SIZE=\"25\" MAXLENGTH=\"50\"><BR><BR><BR>");

          client.println("<INPUT TYPE=SUBMIT NAME=\"submit\" VALUE=\" SUBMIT\">");
          client.println("&nbsp <a href = \"/?mulai\"\"><input type = 'button' value = 'MULAI' ></a>");
          client.println("&nbsp <a href = \"/?set\"\"><input type = 'button' value = 'SETTING' ></a>");
         
          client.println("</FORM>");
          client.println("<BR>");
          client.println("<h5>");    
          client.println("SET DELAY LAMPU MERAH = ");
          client.println(dmerah);
            client.println("<BR>");
          client.println("SET DELAY LAMPU KUNING = ");
          client.println(dkuning);
            client.println("<BR>");
          client.println("SET DELAY LAMPU HIJAU = ");
          client.println(dhijau);
            client.println("<BR>");
          client.println("SET ON LAMPU = ");
          client.println(ton);
            client.println("<BR>");
          client.println("SET OFF LAMPU = ");
          client.println(toff);
            client.println("<BR>");
         
          client.println("</h5>");
          client.println("<BR>");

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

          delay(1);
          //stopping client
          client.stop();
         
         

         
          /////////////////////
          if(readString.indexOf("A10") >0)//checks for on
          {
             lcd.clear();
             lcd.setCursor(0, 0);
             lcd.print("SET DELAY MERAH");
             lcd.setCursor(0, 1);
             lcd.print("10 Detik");
             dmerah = 1000;
             delay(3000);
             lcd.clear();
            
          }
         
          if(readString.indexOf("A20") >0)//checks for off
          {
              lcd.clear();
             lcd.setCursor(0, 0);
             lcd.print("SET DELAY MERAH");
             lcd.setCursor(0, 1);
             lcd.print("20 Detik");
             dmerah = 2000;
             delay(3000);
             lcd.clear();
          }
         
         
          if(readString.indexOf("A30") >0)//checks for off
          {
              lcd.clear();
             lcd.setCursor(0, 0);
             lcd.print("SET DELAY MERAH");
             lcd.setCursor(0, 1);
             lcd.print("30 Detik");
             dmerah = 3000;
             delay(3000);
             lcd.clear();
          }
         
         
         
          if(readString.indexOf("B10") >0)//checks for on
          {
             lcd.clear();
             lcd.setCursor(0, 0);
             lcd.print("SET DELAY KUNING");
             lcd.setCursor(0, 1);
             lcd.print("10 Detik");
             dkuning = 1000;
             delay(3000);
             lcd.clear();
            
          }
         
          if(readString.indexOf("B20") >0)//checks for off
          {
              lcd.clear();
             lcd.setCursor(0, 0);
             lcd.print("SET DELAY KUNING");
             lcd.setCursor(0, 1);
             lcd.print("20 Detik");
             dkuning = 2000;
             delay(3000);
             lcd.clear();
          }
         
         
          if(readString.indexOf("B30") >0)//checks for off
          {
              lcd.clear();
             lcd.setCursor(0, 0);
             lcd.print("SET DELAY KUNING");
             lcd.setCursor(0, 1);
             lcd.print("30 Detik");
             dkuning = 3000;
             delay(3000);
             lcd.clear();
          }
         
         
          if(readString.indexOf("C10") >0)//checks for on
          {
             lcd.clear();
             lcd.setCursor(0, 0);
             lcd.print("SET DELAY HIJAU");
             lcd.setCursor(0, 1);
             lcd.print("10 Detik");
             dhijau = 1000;
             delay(3000);
             lcd.clear();
            
          }
         
          if(readString.indexOf("C20") >0)//checks for off
          {
             lcd.clear();
             lcd.setCursor(0, 0);
             lcd.print("SET DELAY HIJAU");
             lcd.setCursor(0, 1);
             lcd.print("20 Detik");
             dhijau = 2000;
             delay(3000);
             lcd.clear();
          }
         
         
          if(readString.indexOf("C30") >0)//checks for off
          {
             lcd.clear();
             lcd.setCursor(0, 0);
             lcd.print("SET DELAY HIJAU");
             lcd.setCursor(0, 1);
             lcd.print("30 Detik");
             dhijau = 3000;
             delay(3000);
             lcd.clear();
          }
         
         
          if(readString.indexOf("D2") >0)//checks for off
          {
             lcd.clear();
             lcd.setCursor(0, 0);
             lcd.print("SET ON LAMPU");
             lcd.setCursor(0, 1);
             lcd.print("JAM 07.00 AM");
             ton = 2;
             delay(3000);
             lcd.clear();
          }
         
         
          if(readString.indexOf("D18") >0)//checks for off
          {
             lcd.clear();
             lcd.setCursor(0, 0);
             lcd.print("SET ON LAMPU");
             lcd.setCursor(0, 1);
             lcd.print("JAM 08.00 AM");
             ton = 18;
             delay(3000);
             lcd.clear();
          }
         
         
          if(readString.indexOf("E2") >0)//checks for off
          {
             lcd.clear();
             lcd.setCursor(0, 0);
             lcd.print("SET OFF LAMPU");
             lcd.setCursor(0, 1);
             lcd.print("JAM 22.00 PM");
             toff = 2;
             delay(3000);
             lcd.clear();
          }
         
         
          if(readString.indexOf("E18") >0)//checks for off
          {
             lcd.clear();
             lcd.setCursor(0, 0);
             lcd.print("SET OFF LAMPU");
             lcd.setCursor(0, 1);
             lcd.print("JAM 21.00 PM");
             toff = 18;
             delay(3000);
             lcd.clear();
          }
         
          if(readString.indexOf("?mulai") >0)//checks for off
          {
             lcd.clear();
             lcd.setCursor(0, 0);
             lcd.print("START PROGRAM");
             lcd.setCursor(0, 1);
             lcd.print("LOADING....");
             delay(3000);
             lcd.clear();
          }
         
         
          if(readString.indexOf("?set") >0)//checks for off
          {
             lcd.clear();
             lcd.setCursor(0, 0);
             lcd.print("MODE SETTING");
             lcd.setCursor(0, 1);
             lcd.print("LOADING....");
             delay(3000);
             lcd.clear();
          }
         
           while (readString.indexOf("?mulai") >0) {
                mulai();
          }
         

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

        }
      }
    }
  }
}


void mulai(){

  displayTime();
 

  // 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();

          client.println("<HTML>");
          client.println("<HEAD>");
          client.println("<TITLE>Arduino GET test page</TITLE>");
          client.println("</HEAD>");
          client.println("<BODY>");

          client.println("<H3>kontrol ON / OFF dan delay lampu</H3>");

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

          client.println("Delay Lampu Merah : <INPUT TYPE=TEXT NAME=\"Merah\" VALUE=\"A\" SIZE=\"25\" MAXLENGTH=\"50\"><BR><BR><BR>");
          client.println("Delay Lampu Kuning: <INPUT TYPE=TEXT NAME=\"Kuning\" VALUE=\"B\" SIZE=\"25\" MAXLENGTH=\"50\"><BR><BR><BR>");
          client.println("Delay Lampu Hijau : <INPUT TYPE=TEXT NAME=\"Hijau\" VALUE=\"C\" SIZE=\"25\" MAXLENGTH=\"50\"><BR><BR><BR>");
  
          client.println("Jam ON : <INPUT TYPE=TEXT NAME=\"LEDON\" VALUE=\"D\" SIZE=\"25\" MAXLENGTH=\"50\"><BR><BR><BR>");
          client.println("Jam OFF : <INPUT TYPE=TEXT NAME=\"LEDOFF\" VALUE=\"E\" SIZE=\"25\" MAXLENGTH=\"50\"><BR><BR><BR>");

          client.println("<INPUT TYPE=SUBMIT NAME=\"submit\" VALUE=\" SUBMIT\">");
          client.println("&nbsp <a href = \"/?mulai\"\"><input type = 'button' value = 'MULAI' ></a>");
          client.println("&nbsp <a href = \"/?set\"\"><input type = 'button' value = 'SETTING' ></a>");
         
          client.println("</FORM>");
          client.println("<BR>");
          client.println("<h5>");    
          client.println("SET DELAY LAMPU MERAH = ");
          client.println(dmerah);
            client.println("<BR>");
          client.println("SET DELAY LAMPU KUNING = ");
          client.println(dkuning);
            client.println("<BR>");
          client.println("SET DELAY LAMPU HIJAU = ");
          client.println(dhijau);
            client.println("<BR>");
          client.println("SET ON LAMPU = ");
          client.println(ton);
            client.println("<BR>");
          client.println("SET OFF LAMPU = ");
          client.println(toff);
            client.println("<BR>");
         
          client.println("</h5>");
          client.println("<BR>");

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

          delay(1);
          //stopping client
          client.stop();
         
                
          //clearing string for next read
          readString="";

        }
      }
    }
  }
}




f. Tampilan Interface WEB





g. Cara Penggunaan Alat


            Untuk menggunakan alat ini sangat lah mudah, yaitu masukkan nilai misal pada Delay lampu merah A10, lalu klik SUBMIT, setelah itu KLIK SETTING, kemudian masukkan nilai delay lampu kuning B20 untuk delay 20 detik, begitu seterusnya, jika berhasil maka nilai akan tersimpan pada bagian bawah form, jika sudah terisi semua nilainya KLIK MULAI, maka akan berjalan sesuai delay yang disetting, untuk kembali ke mode setting bisa dengan menekan tombol SETTING.