/* JUDUL : PROGRAM JAM DIGITAL P10 1 PANEL DENGAN NANO & RTC 3231
* COPY RIGHT : BELAJAR TEHNOLOGI JAMAN NOW
* PUBLISH : 13 MAR 2022
* EMAIL : aplikasihebatstudio@gmail.com
*
* NANO - P10
* ----------
* PIN YANG DISAMBUNG
* Arduino P-10
* D6 -> A
* D7 -> B
* D8 -> SCLK
* D9 -> OE (ENABLE)
* D11 -> DATA
* D13 -> CLK
* GND -> GND
RTC 3231
--------
* GND >> Pin GND
* VCC >> Pin 5V
* SDA >> Pin SDA (A4)
* SCL >> Pin SCL (A5)
* SQW >> tidak dihubungkan
* 32K >> tidak dihubungkan
*/
#include <Wire.h>
#include "RTClib.h"
#include "DMD.h"
#include "TimerOne.h"
#include "SystemFont5x7.h"
#include "angka6x13.h"
#include "angka_2.h"
#define DISPLAYS_ACROSS 1
#define DISPLAYS_DOWN 1
/***** P10 DISPLAY SETTING ***********************************/
DMD dmd( DISPLAYS_ACROSS , DISPLAYS_DOWN);
RTC_DS3231 rtc;
// int tahun;
byte jam;
byte menit; //|
byte detik;
void drawText(int kolom,int baris,String text);
void ScanDMD()
{
dmd.scanDisplayBySPI();
}
void setup()
{
Timer1.initialize( 4000 ); // I find the default 5000 gives a visible flicker
Timer1.attachInterrupt( ScanDMD );
dmd.selectFont(SystemFont5x7);
dmd.clearScreen( true );
Wire.begin();
rtc.begin();
// just datatime
// rtc.adjust(DateTime(2022, 03, 12, 12, 8, 0));
}
void loop()
{
jam_besar(10);
gambar_masjid();
delay(5000);
drawText1(32,16," ");
delay(1000);
}
void jam_besar(int lama)
{
dmd.clearScreen(true);
//dmd.drawBox(32,0,63,15,GRAPHICS_ON);
for (int i=0;i<=lama;i++)
{
DateTime now = rtc.now();
int jam= now.hour();
int menit=now.minute();
int detik=now.second();
String waktu1=Konversi(jam)+":"+Konversi(menit)+":"+Konversi(detik);
String waktu2=Konversi(jam)+" "+Konversi(menit)+" "+Konversi(detik);;
dmd.selectFont(angka6x13);
drawText(1, 0, Konversi(jam)); //koordinat tampilan
//titik 2
dmd.drawLine(16,4,16,5,GRAPHICS_NORMAL);
dmd.drawLine(15,4,15,5,GRAPHICS_NORMAL);
dmd.drawLine(16,9,16,10,GRAPHICS_NORMAL);
dmd.drawLine(15,9,15,10,GRAPHICS_NORMAL);
dmd.selectFont(angka6x13);
drawText(18, 0, Konversi(menit));
delay(500);
dmd.drawLine(16,4,16,5,GRAPHICS_NOR);
dmd.drawLine(15,4,15,5,GRAPHICS_NOR);
dmd.drawLine(16,9,16,10,GRAPHICS_NOR);
dmd.drawLine(15,9,15,10,GRAPHICS_NOR);
delay(500);
}
dmd.clearScreen(true);
}
void drawText(int kolom,int baris,String text)
{
int pj_text=text.length()+1;
char text_char[pj_text];
text.toCharArray(text_char,pj_text);
dmd.drawString(kolom,baris,text_char,pj_text,GRAPHICS_NORMAL);
}
///Konversi angka agar ada nol didepannya jika diawah 10
String Konversi(int sInput) {
if (sInput < 10)
{
return"0" + String(sInput);
}
else
{
return String(sInput);
}
}
void gambar_masjid()
{
int GRAPHICS_ON=GRAPHICS_NORMAL;
// dmd.clearScreen(true);
//dmd.drawBox(32,0,63,15,GRAPHICS_ON);
//gambar masjid
//kiri
dmd.drawLine(0,6,0,6,GRAPHICS_NORMAL);
dmd.drawLine(1,5,1,15,GRAPHICS_ON);
dmd.drawLine(2,0,2,13,GRAPHICS_ON);
dmd.drawLine(3,5,3,15,GRAPHICS_ON);
dmd.drawLine(4,6,4,6,GRAPHICS_ON);
//tengah
dmd.drawLine(15,0,15,0,GRAPHICS_ON);
dmd.drawLine(14,1,16,1,GRAPHICS_ON);
dmd.drawLine(13,2,17,2,GRAPHICS_ON);
dmd.drawLine(12,3,18,3,GRAPHICS_ON);
dmd.drawLine(11,4,19,4,GRAPHICS_ON);
dmd.drawLine(11,5,19,5,GRAPHICS_ON);
dmd.drawLine(12,6,18,6,GRAPHICS_ON);
dmd.drawLine(13,7,17,7,GRAPHICS_ON);
dmd.drawLine(5,8,25,8,GRAPHICS_ON);
dmd.drawLine(5,10,25,10,GRAPHICS_ON);
dmd.drawLine(5,11,7,11,GRAPHICS_ON);dmd.drawLine(9,11,14,11,GRAPHICS_ON);dmd.drawLine(16,11,21,11,GRAPHICS_ON);dmd.drawLine(23,11,25,11,GRAPHICS_ON);
dmd.drawLine(5,12,6,12,GRAPHICS_ON);dmd.drawLine(10,12,13,12,GRAPHICS_ON);dmd.drawLine(17,12,20,12,GRAPHICS_ON);dmd.drawLine(24,12,25,12,GRAPHICS_ON);
dmd.drawLine(5,13,6,13,GRAPHICS_ON);dmd.drawLine(10,13,13,13,GRAPHICS_ON);dmd.drawLine(17,13,20,13,GRAPHICS_ON);dmd.drawLine(24,13,25,13,GRAPHICS_ON);
dmd.drawLine(5,14,6,14,GRAPHICS_ON);dmd.drawLine(10,14,13,14,GRAPHICS_ON);dmd.drawLine(17,14,20,14,GRAPHICS_ON);dmd.drawLine(24,14,25,14,GRAPHICS_ON);
dmd.drawLine(5,15,25,15,GRAPHICS_ON);
//kanan
dmd.drawLine(26,6,26,6,GRAPHICS_ON);
dmd.drawLine(27,5,27,15,GRAPHICS_ON);
dmd.drawLine(28,0,28,13,GRAPHICS_ON);
dmd.drawLine(29,5,29,15,GRAPHICS_ON);
dmd.drawLine(30,6,30,6,GRAPHICS_ON);
//delay(2000);
}
void drawText1(int kolom,int baris,String text)
{
long RandNumX;
long RandNumY;
//RandNumX=random(kolom);
//RandNumY=random(baris);
for(int i=0;i<1500;i++)
{
RandNumX=random(kolom);
RandNumY=random(baris);
dmd.drawLine( RandNumX, RandNumY, RandNumX+2, RandNumY+2, GRAPHICS_NOR );
delay(1);
}
//dmd.drawString(kolom,baris,text_char,pj_text,GRAPHICS_NOR);
}
No comments:
Post a Comment