/*
program ini hanya untuk uji coba pemuatan bell.
*/
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 20, 4);
int jam = 0;
int menit = 0;
int detik = 0;
unsigned long previousMillis = 0;
const long interval = 100; // interval dalam milidetik (1000ms = 1 detik)
//const int suara[] = {"satu", 2, 3, 4, 5, 6, 7, 8, 9}; // Angka-angka sesuai dengan tipe data integer
const char* suara[] = { "satu", "dua", "tiga", "empat", "lima", "enam", };
byte selectedparm1 ;
byte jamInput1[30];
byte menitInput1[30];
void setup() {
// put your setup code here, to run once:
pinMode(4, OUTPUT);
digitalWrite(4, HIGH);
delay(1000);
digitalWrite(4, LOW);
Serial.begin(9600);
jamInput1[0] = 20;
menitInput1[0] = 0;
jamInput1[1] = 20;
menitInput1[1] = 3;
jamInput1[2] = 20;
menitInput1[2] = 5;
jam = 19;
menit = 59;
detik = 0;
selectedparm1 = 0;
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Connecting to Blynk ");
}
void loop() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
updateWaktu();
tampilkanWaktu();
}
playSound() ;
}
void tampilkanWaktu() {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Waktu:");
lcd.setCursor(0, 1);
lcd.print(String(jam) + ":" + String(menit) + ":" + String(detik));
}
void updateWaktu() {
detik++;
if (detik == 60) {
detik = 0;
menit++;
if (menit == 60) {
menit = 0;
jam++;
if (jam == 24) {
jam = 0;
}
}
}
}
void playSound() {
for (int i = 0; i < 30; ++i) {
if ((jamInput1[i] == jam) && (menitInput1[i] == menit) && (detik < 1)) {
Serial.print(i);
}
}
}