[csharp] ce

Viewer

  1. #include <LiquidCrystal.h>
  2. #include <RTClib.h>
  3. #include <Wire.h>
  4. RTC_DS1307 RTC;
  5. LiquidCrystal lcd(1312111098);
  6.  
  7. int LampuTeras = 3;
  8. int LampuBalkon = 4;
  9. int LampuTengah = 5;
  10. int LampuKamar = 6;
  11. int jam, menit, detik, tanggal, bulan, tahun, hari;
  12. char temp[33];
  13. char namahari[7][8] = {"Minggu""Senin""Selasa""Rabu""Kamis""Jumat""Sabtu"};
  14.  
  15. void setup() {
  16.   Serial.begin(115200);
  17.   RTC.begin();
  18.   lcd.begin(162);// put your setup code here, to run once:
  19.   pinMode(3, OUTPUT);
  20.   pinMode(4, OUTPUT);
  21.   pinMode(5, OUTPUT);
  22.   pinMode(6, OUTPUT);
  23.   lcd.setCursor(40);
  24.   lcd.print("KELOMPOK");
  25.   lcd.setCursor(71);
  26.   lcd.print("02");
  27.   delay(1000);
  28.   lcd.clear();
  29. }
  30.  
  31. void loop() {
  32.   DateTime now = RTC.now();
  33.   jam = now.hour();
  34.   menit = now.minute();
  35.   detik = now.second();
  36.   tanggal = now.day();
  37.   bulan = now.month();
  38.   tahun = now.year();
  39.   hari = now.dayOfTheWeek();
  40.  
  41.   sprintf(temp, "%02d:%02d:%02d WIB", jam, menit, detik);
  42.   lcd.setCursor(20);
  43.   lcd.print(temp);
  44.  
  45.   sprintf(temp, "%s,%02d/%02d/%02d", namahari[hari], tanggal, bulan, tahun);
  46.   lcd.setCursor(01);
  47.   lcd.print(temp);
  48.  
  49.   if (jam == 18 && menit == 00 && detik == 00) {
  50.     digitalWrite(3, HIGH);
  51.     digitalWrite(4, HIGH);
  52.   }
  53.   if (jam == 17 && menit == 00 && detik == 00) {
  54.     digitalWrite(5, HIGH);
  55.     digitalWrite(6, HIGH);
  56.   }
  57.   else if (jam == 06 && menit == 00 && detik == 00) {
  58.     digitalWrite(3, LOW);
  59.     digitalWrite(4, LOW);
  60.     digitalWrite(5, LOW);
  61.     digitalWrite(6, LOW);
  62.   }
  63.  
  64.   // put your main code here, to run repeatedly:
  65.  
  66. }
  67.  

Editor

You can edit this paste and save as new:


File Description
  • ce
  • Paste Code
  • 29 Mar-2024
  • 1.57 Kb
You can Share it: