Rangkaian Jam Digital Led Matrix

on
Categories: Belajar Arduino, Mikrokontroller

Buat kalian yang seneng banget mainan atau ngoprek ngoprek rangkaian arduino, alat yang akan saya bahas di artikel ini mungkin cocok banget buat kamu coba.

Saya akan membagikan project jam digital LED Matrix thermometer kepada kalian para pembaca duwiarsana.com, tapi sebelum itu saya akan terangkan dulu seperti apa jam digital yang akan saya bahas disini.

Jam digital LED matrix ini nantinya akan menggunakan display LED matrix dengan tipe P10. Dimana display dengan tipe ini sudah sangat lumrah dijual di toko sparepart online. Data yang akan ditampilkan akan menjadi beberapa model, yaitu ; Jam digital besar, Jam digital beserta kalender, Thermometer, dan juga jam digital yang dilengkapi dengan hari.

Rangkaian ini sudah dilengkapi dengan IC RTC sehingga data jam tidak akan hilang saat terjadinya pemadaman listrik, atau saat rangkaian itu tidak mendapatkan sumber tegangan.

Untuk mikrokontroler nya saya menggunakan atmega328 yang dimana ini sama dengan ic yang dipakai pada arduino, sehingga kalian juga bisa membuat jam digital ini dengan menggunakan arduino biasa seperti yang pernah say lakukan di video tersebut.

Skematik

Layout PCB

Layout PCB Atas
Layout PCB Bawah

Komponen yang Dipakai

Untuk komponen apa saja yang digunakan dalam project ini memang terlihat banyak sekali, tapi sebenarnya komponen yang dipakai pada PCB yang di design dalam ukuran kecil ini memiliki komponen bahkan lebih sedikit dari board arduino itu sendiri. ditambah dengan sudah adanya modul RTC pada design ini.

Komponen tersebut terdiri dari resistor yang kesemua nya bernilai 1k, kapasitor 100nF kecuali pada kristal 16Mhz menggunakan kristal 22pF. Untuk RTC nya menggunakan IC DS1307 dan kristal 32.768KHz. Lalu konektor battery, tactile switch, elco 10uF, sensor suhu DS18B20, header dan terminal screw.

Baca juga  Download Project Kontroler Jadwal Sholat

Untuk IC mikrokontroler atmega328 nya sendiri harus kita program dulu dengan menggunakan USBASP sebelum kita menyolder nya ke papan PCB.

Coding Arduino

Sebelum kalian menerapkan coding arduino ini, kalian harus melengkapi dulu library yang diperlukan. Seperti DMD, font nya, wire dan RTClib. Semua itu bisa kalian download pada artikel ini.

[sociallocker]

#include
#include
#include
#include
#include "SystemFont5x7.h"
#include "Jam9.h"
#include "Arial14.h"
#include "Arial_black_16.h"
#include "RTClib.h"
#include #include
#include

#define DISPLAYS_ACROSS 1
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);
OneWire ds(14);
RTC_DS1307 RTC;
char buffer[10];
char buffer2[8];
int key=3;
int hours;
int thn,bln,hr;
int dayOfWeek, dayOfMonth;
int hh;
int mm,z;
int sementara;
int ss;
int hitung=0;
int seconds;
int minutes;

int day;
int date;
int xx;
int month;
int year;
int tb1=0;
int tb2=1;
int tb3=2;
PString str(buffer, sizeof(buffer));
PString str2(buffer2, sizeof(buffer2));
void ScanDMD()
{
dmd.scanDisplayBySPI();
}
boolean a,b,c;
void setup()
{
delay(1000);
//Serial.begin(9600);
pinMode(key,INPUT_PULLUP);
pinMode(tb1,INPUT_PULLUP);
pinMode(tb2,INPUT_PULLUP);
pinMode(tb3,INPUT_PULLUP);
Timer1.initialize( 1500 );
Timer1.pwm(PIN_DMD_nOE, 150);
Timer1.attachInterrupt( ScanDMD );
dmd.clearScreen( true );
Wire.begin();
RTC.begin();
if (! RTC.isrunning()) {

RTC.adjust(DateTime(__DATE__, __TIME__));
}

Wire.beginTransmission(0X68);
Wire.write(0x07);
Wire.write(0x10);
Wire.endTransmission();
float temperature = getTemp();

}
void baca(){

a=digitalRead(tb1);
b=digitalRead(tb2);
c=digitalRead(tb3);
}
void loop(){
float temperature = getTemp();
//dmd.clearScreen( true );
awal:
DateTime now = RTC.now();
//dayOfWeek=now.dayOfTheWeek();
str.begin();
ambiltanggal();
hours = now.hour();
mm = now.minute();
ss = now.second();
baca();
// sementara=mm;
if(sementara!=mm){
dmd.clearScreen( true );
dmd.selectFont(Arial_Black_16);
int u=0;

while(u<15){
//dayOfWeek=now.dayOfTheWeek();
//str.begin();
ambiltanggal();
hours = now.hour();
mm = now.minute();
ss = now.second();
str.begin();
if(hours<10){str.print("0");}
str.print (hours);
dmd.drawString(0,0,str,str.length(),GRAPHICS_NORMAL );
str.begin();
str.print(":");
dmd.drawString(14,0,str,str.length(),GRAPHICS_OR );
str.begin();
if(mm<10){str.print("0");}
str.print (mm);
dmd.drawString(19,0,str,str.length(),GRAPHICS_NORMAL );
delay(500);
str.begin();
if(hours<10){str.print("0");}
str.print (hours);
dmd.drawString(0,0,str,str.length(),GRAPHICS_NORMAL );
str.begin();
str.print(":");
dmd.drawString(14,0,str,str.length(),GRAPHICS_NOR );
str.begin();
if(mm<10){str.print("0");}
str.print (mm);
dmd.drawString(19,0,str,str.length(),GRAPHICS_NORMAL );
delay(500);
u++;
}
u=0;
str.begin();
dmd.clearScreen( true );
while(u<4){
ambiltanggal();
hours = now.hour();
mm = now.minute();
ss = now.second();
str.begin();
if(hours<10){str.print("0");}
str.print(hours);
dmd.selectFont(Jam_9);
dmd.drawString(3,-7,str,str.length(),GRAPHICS_NORMAL );
str.begin();
if(mm<10){str.print("0");}
str.print(mm);
dmd.drawString(18,-7,str,str.length(),GRAPHICS_NORMAL );
dmd.drawString(15,-7,":",1,GRAPHICS_OR );
delay(500);
str.begin();
if(hours<10){str.print("0");}
str.print(hours);
dmd.drawString(3,-7,str,str.length(),GRAPHICS_NORMAL );
dmd.drawString(15,-7,":",1,GRAPHICS_NOR );
str.begin();
if(mm<10){str.print("0");}
str.print(mm);
dmd.drawString(18,-7,str,str.length(),GRAPHICS_NORMAL );
delay(500);
dmd.selectFont(Arial_14);
str.begin();
//str.print(day);
ambiltanggal();
if(date<10){str.print("0");}
str.print(date);
str.print("-");
if(month<10){str.print("0");}
str.print(month);
str.print("-");
str.print(year);
dmd.drawString(1,10,str,str.length(),GRAPHICS_NORMAL );
u++;

}

u=0;
str.begin();
dmd.clearScreen( true );

while(u<4){
str.begin();
str.print(temperature,1);
dmd.selectFont(Jam_9);
dmd.drawString(6,-7,str,str.length(),GRAPHICS_NORMAL );
dmd.selectFont(Arial_14);
str.begin();
str.print("CELSIUS");
dmd.drawString(0,10,str,str.length(),GRAPHICS_NORMAL );
delay(1000);
u++;
}
// dmd.clearScreen( true );
// dmd.selectFont(Arial_Black_16);
// dmd.drawMarquee("Om Swastyastu..",15,(32*DISPLAYS_ACROSS)-1,0);
// long start=millis();
// long timer=start;
// boolean ret=false;
// while(!ret){
// if ((timer+30) < millis()) {
// ret=dmd.stepMarquee(-1,0);
// timer=millis();
// }
// }

str.begin();
dmd.clearScreen( true );
sementara=mm;
}
if(!a){
dmd.clearScreen( true );
delay(1000);
baca();
while(a){
dmd.selectFont(Jam_9);
baca();
str2.begin();
if(hours<10){str2.print("0");} str2.print(hours); dmd.drawString(11,-7,str2,str2.length(),GRAPHICS_NORMAL ); str2.begin(); dmd.selectFont(Arial_14); str2.print("JAM"); dmd.drawString(8,10,str2,str2.length(),GRAPHICS_NORMAL ); //elay(00); if(!b){ dmd.clearScreen( true ); hours+=1; if(hours>23){hours=0;}
delay(200);
}
if(!c){
dmd.clearScreen( true );
hours-=1;
if(hours<0){hours=23;}
delay(200);
}
if(!a){
dmd.clearScreen( true );
delay(1000);
baca();
while(a){
dmd.selectFont(Jam_9);
baca();
str2.begin();
if(mm<10){str2.print("0");} str2.print(mm); dmd.drawString(11,-7,str2,str2.length(),GRAPHICS_NORMAL ); str2.begin(); dmd.selectFont(Arial_14); str2.print("MENIT"); dmd.drawString(4,10,str2,str2.length(),GRAPHICS_NORMAL ); if(!b){ dmd.clearScreen( true ); mm+=1; if(mm>59){mm=0;}
delay(200);
}
if(!c){
dmd.clearScreen( true );
mm-=1;
if(mm<0){mm=59;} delay(200); } if(!a){ dmd.clearScreen( true ); delay(1000); baca(); ambiltanggal(); while(a){ dmd.selectFont(Jam_9); baca(); str2.begin(); str2.print("20"); str2.print(year); dmd.drawString(5,-7,str2,str2.length(),GRAPHICS_NORMAL ); str2.begin(); dmd.selectFont(Arial_14); str2.print("TAHUN"); dmd.drawString(3,10,str2,str2.length(),GRAPHICS_NORMAL ); if(!b){ dmd.clearScreen( true ); year+=1; if(year>99){year=16;}
delay(200);

}
if(!c){
dmd.clearScreen( true );
year-=1;
if(year<2016){year=2099;}
delay(200);

}

if(!a){
dmd.clearScreen( true );
delay(1000);
baca();
while(a){
dmd.selectFont(Jam_9);
baca();
str2.begin();
if(month<10){str2.print("0");} str2.print(month); dmd.drawString(11,-7,str2,str2.length(),GRAPHICS_NORMAL ); str2.begin(); dmd.selectFont(Arial_14); str2.print("BULAN"); dmd.drawString(3,10,str2,str2.length(),GRAPHICS_NORMAL ); if(!b){ dmd.clearScreen( true ); month+=1; if(month>12){month=1;}
delay(200);
}
if(!c){
dmd.clearScreen( true );
month-=1;
if(month<1){month=12;}
delay(200);
}
if(!a){
dmd.clearScreen( true );
delay(1000);
baca();
ambiltanggal();

suit();
while(a){
//ambiltanggal();
dmd.selectFont(Jam_9);
baca();
str2.begin();
if(date<10){str2.print("0");} str2.print(date); dmd.drawString(11,-7,str2,str2.length(),GRAPHICS_NORMAL ); str2.begin(); dmd.selectFont(Arial_14); str2.print("TGL"); dmd.drawString(9,10,str2,str2.length(),GRAPHICS_NORMAL ); if(!b){ dmd.clearScreen( true ); date+=1; if(date>xx){date=1;}
delay(200);
}
if(!c){
dmd.clearScreen( true );
date-=1;
if(date<1){date=xx;} delay(200); } if(!a){ dmd.clearScreen( true ); delay(1000); baca(); while(a){ baca(); str.begin(); dmd.selectFont(Arial_14); if(z==7){ str.print("MINGGU"); dmd.drawString(1,10,str,str.length(),GRAPHICS_NORMAL ); } if(z==1){ str.print("SENIN"); dmd.drawString(4,10,str,str.length(),GRAPHICS_NORMAL ); } if(z==2){ str.print("SELASA"); dmd.drawString(1,10,str,str.length(),GRAPHICS_NORMAL ); } if(z==3){ str.print("RABU"); dmd.drawString(6,10,str,str.length(),GRAPHICS_NORMAL ); } if(z==4){ str.print("KAMIS"); dmd.drawString(4,10,str,str.length(),GRAPHICS_NORMAL ); } if(z==5){ str.print("JUMAT"); dmd.drawString(3,10,str,str.length(),GRAPHICS_NORMAL ); } if(z==6){ str.print("SABTU"); dmd.drawString(4,10,str,str.length(),GRAPHICS_NORMAL ); } if(!b){ dmd.clearScreen( true ); z+=1; if(z>7){z=1;}
delay(200);
day=z;
}
if(!c){
dmd.clearScreen( true );
z-=1;
if(z<1){z=7;}
delay(200);
day=z;
}

if(!a){
dmd.clearScreen( true );
delay(1000);
goto awal;

}

// aturtanggal();

//updateRTC();
//day=z;
aturtanggal();

}

//updateRTC();
}

updateRTC();
}

}

updateRTC();
}

}

updateRTC();
}

}

updateRTC();
}
}

updateRTC();
}
}
if(hours<10){str.print("0");}
str.print(hours);
dmd.selectFont(Jam_9);
dmd.drawString(3,-7,str,str.length(),GRAPHICS_NORMAL );
str.begin();
if(mm<10){str.print("0");}
str.print(mm);
dmd.drawString(18,-7,str,str.length(),GRAPHICS_NORMAL );
dmd.drawString(15,-7,":",1,GRAPHICS_OR );
delay(500);

str.begin();
if(hours<10){str.print("0");}
str.print(hours);
dmd.drawString(3,-7,str,str.length(),GRAPHICS_NORMAL );
dmd.drawString(15,-7,":",1,GRAPHICS_NOR );
str.begin();
if(mm<10){str.print("0");}
str.print(mm);
dmd.drawString(18,-7,str,str.length(),GRAPHICS_NORMAL );
dmd.selectFont(Arial_14);
str.begin();
//str.print(day);
ambiltanggal();
//dayOfWeek=now.dayOfTheWeek();
z=day;
if(day==7){
str.print("MINGGU");
dmd.drawString(1,10,str,str.length(),GRAPHICS_NORMAL );
}
if(day==1){
str.print("SENIN");
dmd.drawString(4,10,str,str.length(),GRAPHICS_NORMAL );
}
if(day==2){
str.print("SELASA");
dmd.drawString(1,10,str,str.length(),GRAPHICS_NORMAL );
}
if(day==3){
str.print("RABU");
dmd.drawString(6,10,str,str.length(),GRAPHICS_NORMAL );
}
if(day==4){
str.print("KAMIS");
dmd.drawString(4,10,str,str.length(),GRAPHICS_NORMAL );
}
if(day==5){
str.print("JUMAT");
dmd.drawString(3,10,str,str.length(),GRAPHICS_NORMAL );
}
if(day==6){
str.print("SABTU");
dmd.drawString(4,10,str,str.length(),GRAPHICS_NORMAL );
}
delay(500);
dmd.selectFont(Arial_14);
str.begin();
//str.print(day);
ambiltanggal();

z=day;
if(day==7){
str.print("MINGGU");
dmd.drawString(1,10,str,str.length(),GRAPHICS_NORMAL );
}
if(day==1){
str.print("SENIN");
dmd.drawString(4,10,str,str.length(),GRAPHICS_NORMAL );
}
if(day==2){
str.print("SELASA");
dmd.drawString(1,10,str,str.length(),GRAPHICS_NORMAL );
}
if(day==3){
str.print("RABU");
dmd.drawString(6,10,str,str.length(),GRAPHICS_NORMAL );
}
if(day==4){
str.print("KAMIS");
dmd.drawString(4,10,str,str.length(),GRAPHICS_NORMAL );
}
if(day==5){
str.print("JUMAT");
dmd.drawString(3,10,str,str.length(),GRAPHICS_NORMAL );
}
if(day==6){
str.print("SABTU");
dmd.drawString(4,10,str,str.length(),GRAPHICS_NORMAL );
}

}

void ambiltanggal()
{
delay(100);
Wire.beginTransmission(104);
Wire.write(3);
Wire.endTransmission();
Wire.requestFrom(104,4);
day = bcdToDec(Wire.read());
date = bcdToDec(Wire.read());
month = bcdToDec(Wire.read());
year = bcdToDec(Wire.read());
//Serial.println(year);
Wire.endTransmission();
}

byte decToBcd(byte val)
{
return ( (val/10*16) + (val%10) );
}

byte bcdToDec(byte val)
{
return ( (val/16*10) + (val%16) );
}

void updateRTC() {
delay(100);
Wire.beginTransmission(104);
Wire.write(0);
Wire.write(decToBcd(ss));
Wire.write(decToBcd(mm));
Wire.write(decToBcd(hours));
Wire.write(decToBcd(z));
Wire.write(decToBcd(date));
Wire.write(decToBcd(month));
// year=year-1000;
Wire.write(decToBcd(year));
Wire.endTransmission();

}

void suit()
{
switch (month)
{
case 1:
xx=31;
break;
case 2:
if (year%4==0)
{
if(year%100==0)
{
if(year%400==0)
{
xx=29;
}
else
xx=28;
}
else
xx=29;
}
else
xx=28;
break;
case 3:
xx=31;
break;
case 4:
xx=30;
break;
case 5:
xx=31;
break;
case 6:
xx=30;
break;
case 7:
xx=31;
break;
case 8:
xx=31;
break;
case 9:
xx=30;
break;
case 10:
xx=31;
break;
case 11:
xx=30;
break;
case 12:
xx=31;
break;

}
}

void aturtanggal()
{
delay(100);
//year=year-1000;
Wire.beginTransmission(104);
Wire.write(3);
Wire.write(decToBcd(day));
Wire.write(decToBcd(date));
Wire.write(decToBcd(month));
Wire.write(decToBcd(year));
Wire.endTransmission();

}

float getTemp(){

byte data[12];
byte addr[8];

if ( !ds.search(addr)) {

ds.reset_search();
return -1000;
}

if ( OneWire::crc8( addr, 7) != addr[7]) {
return -1000;
}

if ( addr[0] != 0x10 && addr[0] != 0x28) {
return -1000;
}

ds.reset();
ds.select(addr);
ds.write(0x44,1);
byte present = ds.reset();
ds.select(addr);
ds.write(0xBE);

for (int i = 0; i < 9; i++) {
data[i] = ds.read();
}

ds.reset_search();

byte MSB = data[1];
byte LSB = data[0];

float tempRead = ((MSB << 8) | LSB);
float TemperatureSum = tempRead / 16;

return TemperatureSum;

}

[/sociallocker]

Baca juga  Apa itu E-Ink E-paper?

 

Download

[su_button url=”http://turboagram.com/4lGP” target=”blank” style=”flat”background=”#ef2d63″ size=”5″ icon=”icon: file-code-o” desc=”Coding Arduino”]Klik Untuk Download[/su_button]
[su_button url=”http://turboagram.com/4lNl” target=”blank” style=”flat” background=”#ef2d63″ size=”5″ icon=”icon: file-code-o” desc=”Layout PCB”]Klik Untuk Download[/su_button]
[su_button url=”http://turboagram.com/4lSV” target=”blank” style=”flat” background=”#ef2de2″ size=”5″ icon=”icon: file-code-o” desc=”Skematik”]Klik Untuk Download[/su_button]
 

[su_youtube url=”https://www.youtube.com/watch?v=bfrZOaGjBFM”]