--> Project I.10. Kalender Digital dengan Tampilan LCD berbasis Arduino Uno | Tutorial arduino lengkap

Tuesday, August 1, 2017

Project I.10. Kalender Digital dengan Tampilan LCD berbasis Arduino Uno

| Tuesday, August 1, 2017
I.10. Kalender Digital dengan Tampilan LCD


Sistem Kerja Alat


Arduino membaca data RTC (Real Time Clock) data yang diperoleh berupa jam, menit, detik, hari ke-, tanggal, bulan dan tahun. Hasil pembacaan data RTC kemudian ditampilkan pada LCD 2x16. LCD menampilkan jam , hari dan tanggal. Disamping menapilkan display tersebut jam dapat diseting dengan 4 tombol yaitu tombol Next, Back, Up dan Down.

Kebutuhan Hardware 

  • Modul LCD 2x16
  • Modul RTC DS1307
  • 4 Tombol push ON
  • Modul Arduino UNO
  • Power supply +9Volt

Push Button (Source)                       RTC DS13.07 (Source)


 Diagram Blok:

Schematics
Koneksi Arduino UNO:
 Koneksi RTC :
 Koneksi Tombol :

 Source Code/Sketch :
#include <LiquidCrystal.h>
#include "Wire.h"
#define DS1307_ADDRESS 0x68
byte zero = 0x00;
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
int menu;
byte second ,minute,hour, weekDay;
byte monthDay,month,year;
boolean up=false;
boolean down=false;
void setup(){
pinMode(8,INPUT);
pinMode(9,INPUT);
pinMode(10,INPUT);
pinMode(11,INPUT);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
Wire.begin();
lcd.begin(16, 2);
lcd.setCursor(0,0);
lcd.print("Kalender digital");
delay(2000);
lcd.clear();
}
void loop(){
bacaRTC();
lcdDisplay();
cekTombol();
delay(1000);
}
byte decToBcd(byte val){
return ( (val/10*16) + (val%10) );
}
byte bcdToDec(byte val) {
return ( (val/16*10) + (val%16) );
}
void bacaRTC(){
Wire.beginTransmission(DS1307_ADDRESS);
Wire.write(zero);
Wire.endTransmission();
Wire.requestFrom(DS1307_ADDRESS, 7);
second = bcdToDec(Wire.read());
minute = bcdToDec(Wire.read());
hour = bcdToDec(Wire.read() & 0b111111);
weekDay = bcdToDec(Wire.read());
monthDay = bcdToDec(Wire.read());
month = bcdToDec(Wire.read());
year = bcdToDec(Wire.read());
}
void cekTombol(){
if (digitalRead(8)==0){
lcd.clear();
lcd.print("Seting RTC");
delay(2000);
menu++;
lcd.clear();
lcdDisplay();
lcd.blink();
do{
//------------------------next
if (digitalRead(8)==0){
delay(300);
menu++;
}
//--------------------back
else if (digitalRead(9)==0){
delay(300);
if (menu > 1){
menu--;
}
}
//---------------------------up
else if(digitalRead(10)==0){
delay(200);
up=true;
}
//----------------------------down
else if(digitalRead(11)==0){
delay(200);
down=true;
}
//-------------------------edit data jam
if (menu==1){
if (up==true && hour < 24){
hour++;
lcdDisplay();
}
else if (down==true && hour>0){
hour--;
lcdDisplay();
}
up=false;
down=false;
if (hour<10){
lcd.setCursor(5,0);
}
else {
lcd.setCursor(6,0);
}
}
//-------------------------edit data menit
else if (menu==2){
if (up==true && minute < 59){
minute++;
lcdDisplay();
}
else if (down==true && minute>0){
minute--;
lcdDisplay();
}
up=false;
down=false;
if (hour<10 && minute<10){
lcd.setCursor(7,0);
}
else if (hour<10 && minute>9){
lcd.setCursor(8,0);
}
else if (hour>9 && minute<10){
lcd.setCursor(8,0);
}
else if (hour>9 && minute>9){
lcd.setCursor(9,0);
}
}
//-------------------------edit data detik
else if (menu==3){
if (up==true && second < 59){
second++;
lcdDisplay();
}
else if (down==true && second>0){
second--;
lcdDisplay();
}
up=false;
down=false;
if (hour<10 && minute<10 && second<10){
lcd.setCursor(9,0);
}
else if (hour<10 && minute<10 && second>9){
lcd.setCursor(10,0);
}
else if (hour<10 && minute>9 && second<10){
lcd.setCursor(10,0);
}
else if (hour>9 && minute<10 && second<10){
lcd.setCursor(10,0);
}
else if (hour<10 && minute>9 && second>9){
lcd.setCursor(11,0);
}
else if (hour>9 && minute>9 && second<10){
lcd.setCursor(11,0);
}
else if (hour>9 && minute<10 && second>9){
lcd.setCursor(11,0);
}
else if (hour>9 && minute>9 && second>9){
lcd.setCursor(12,0);
}
}
//-------------------------edit data hari
else if (menu==4){
if (up==true && weekDay < 6){
weekDay++;
lcdDisplay();
}
else if (down==true && weekDay>0){
weekDay--;
lcdDisplay();
}
up=false;
down=false;
lcd.setCursor(0,1);
}
//-------------------------edit data tanggal
else if (menu==5){
if (up==true && monthDay < 31){
monthDay++;
lcdDisplay();
}
else if (down==true && monthDay>1){
monthDay--;
lcdDisplay();
}
up=false;
down=false;
if (monthDay<10){
lcd.setCursor(5,1);
}
else {
lcd.setCursor(6,1);
}
}
//-------------------------edit data bulan
else if (menu==6){
if (up==true && month < 12){
month++;
lcdDisplay();
}
else if (down==true && month>1){
month--;
lcdDisplay();
}
up=false;
down=false;
if (monthDay<10 && month<10){
lcd.setCursor(7,1);
}
else if (monthDay<10 && month>9){
lcd.setCursor(8,1);
}
else if (monthDay>9 && month<10){
lcd.setCursor(8,1);
}
else if (monthDay>9 && month>9){
lcd.setCursor(9,1);
}
}
//-------------------------edit data tahun
else if (menu==7){
if (up==true && year < 99){
year++;
lcdDisplay();
}
else if (down==true && year>0){
year--;
lcdDisplay();
}
up=false;
down=false;
if (monthDay<10 && month<10 && year<10){
lcd.setCursor(11,1);
}
else if (monthDay<10 && month<10 && year>9){
lcd.setCursor(12,1);
}
else if (monthDay<10 && month>9 && year<10){
lcd.setCursor(12,1);
}
else if (monthDay>9 && month<10 && year<10){
lcd.setCursor(12,1);
}
else if (monthDay<10 && month>9 && year>9){
lcd.setCursor(13,1);
}
else if (monthDay>9 && month>9 && year<10){
lcd.setCursor(13,1);
}
else if (monthDay>9 && month<10 && year>9){
lcd.setCursor(13,1);
}
else if (monthDay>9 && month>9 && year>9){
lcd.setCursor(14,1);
}
}
//-------------------------simpan data RTC
if (menu==8)setingRTC();
}
while(menu < 8);
lcd.clear();
lcd.noBlink();
lcd.print("Seting RTC OK!");
delay(1000);
lcd.clear();
menu=0;
}
}
void lcdDisplay(){
lcd.setCursor(0,0);
lcd.print("Jam:");
lcd.setCursor(5,0);
lcd.print(hour);
lcd.print(":");
lcd.print(minute);
lcd.print(":");
lcd.print(second);
lcd.print(" ");
lcd.setCursor(0,1);
hari();
lcd.setCursor(5,1);
lcd.print(monthDay);
lcd.print("/");
lcd.print(month);
lcd.print("/20");
lcd.print(year);
lcd.print(" ");
}
void hari(){
if (weekDay==0){
lcd.print("Ming, ");
}
else if (weekDay==1){
lcd.print("Sen,");
}
else if (weekDay==2){
lcd.print("Sel,");
}
else if (weekDay==3){
lcd.print("Rab,");
}
else if (weekDay==4){
lcd.print("Kam,");
}
else if (weekDay==5){
lcd.print("Jum,");
}
else if (weekDay==6){
lcd.print("Sab,");
}
}
void setingRTC(){
Wire.beginTransmission(DS1307_ADDRESS);
Wire.write(zero); //stop RTC
Wire.write(decToBcd(second));
Wire.write(decToBcd(minute));
Wire.write(decToBcd(hour));
Wire.write(decToBcd(weekDay));
Wire.write(decToBcd(monthDay));
Wire.write(decToBcd(month));
Wire.write(decToBcd(year));
Wire.write(zero); //start
Wire.endTransmission();
}


Jalannya Alat :
  1. Koneksikan antara sistem Arduino dengan peripheral lain seperti pada rangkaian (skematik).
  2. Pasang power supply (adaptor 9 V) dan hidupkan (colokkan ke sumber PLN 220V) sehingga lampu LED indikator nyala, LCD juga nyala.
  3. Tampilan pertama pada LCD :

       4. Setelah 2 detik tampil menjadi tampilan normal yaitu menampilkan jam, hari dan tanggal:


       5. Selanjutnya jika ingin merubah/seting jam/tanggal, tekan tombol Next (tombol 1) sehingga
           tampil Seting RTC selama 2 detik:


        6. Kemudian menampilkan kursor berkedip pada jam:


       7. Tekan tombol UP (Tombol 3) untuk menambah jam, sedangkan untuk mengurangi tekan 
           tombol Down (Tombol 4)
       8. Jika sudah sesuai tekan tombol Next, selanjutnya seting menit prosesnya sama dengan seting 
           jam.
       9. Jika sudah seting menit tekan tombol Next lagi untuk seting detik, dan seterusnya.
      10. Apabila ada setingan yang salah Anda bisa mengulangi dengan menekan tombol Back 
           (Tombol 2).
     11. Setelah semua di seting tekan tombol Next untuk menyimpan data tersebut, sehingga LCd 
           menampilkan “Seting RTC OK!”:


     12. Tampilan LCD kembali ke tampilan Normal.
     13. OK!

Video Project I.10. Kalender Digital dengan Tampilan LCD berbasis Arduino Uno



KAMI MELAYANI JASA PEMBUATAN HARDWARE ATAU SOFTWARE BERBASIS ARDUINO

KONTAK KAMI 085743320570 (adi sanjaya)

Related Posts

1 comment:

  1. Bang, kok jam dan tanggal dll malah ga sesuai sma tanggal hari terkini

    ReplyDelete