Kode:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SPI.h> | |
#include <DMD.h> | |
#include <TimerOne.h> | |
#include "SystemFont5x7.h" | |
#include "RTClib.h" | |
#define lebar 1 | |
#define tinggi 1 | |
DMD dmd(lebar, tinggi); | |
RTC_DS3231 rtc; | |
String tanggal, waktu, waktu_sebelum; | |
void ScanDMD() | |
{ | |
dmd.scanDisplayBySPI(); | |
} | |
void setup(void) | |
{ | |
Serial.begin(115200); | |
if (! rtc.begin()) { | |
Serial.println("RTC Tidak Ditemukan"); | |
Serial.flush(); | |
while (1) delay(10); | |
} | |
// membuat timer | |
Timer1.initialize( 5000 ); | |
Timer1.attachInterrupt( ScanDMD ); | |
// inisialisasi DMD | |
dmd.clearScreen( true ); | |
} | |
void loop(void) | |
{ | |
DateTime now = rtc.now(); | |
waktu = String(now.hour()) + ":"; | |
waktu += String(now.minute()); | |
if(waktu != waktu_sebelum){ | |
if(now.day() < 10){ | |
tanggal = "0" + String(now.day()) + "/";} | |
else{ | |
tanggal = String(now.day()) + "/";} | |
tanggal += String(now.month()); | |
dmd.clearScreen( true ); | |
dmd.selectFont(System5x7); | |
dmd.drawString( 1, 0, tanggal.c_str(), tanggal.length(), GRAPHICS_NORMAL ); | |
dmd.drawString( 1, 8, waktu.c_str(), waktu.length(), GRAPHICS_NORMAL ); | |
waktu_sebelum = waktu; | |
} | |
} |
Video:
Kerjasama Robotik ID
https://linktr.ee/robotikidYoutube: https://www.youtube.com/robotikid
Instagram: https://www.instagram.com/robotikid/
Facebook: https://www.facebook.com/RobotikID/
Website: https://www.robotikindonesia.com/
Tokopedia: http://tokopedia.com/instrumentrobot
0 Comments