Arduino Pewaktu 1 Menit (bisa di atur)

okeh lagi-lagi maen arduino … berhubung printer laser hp1000 rusak jadi ngga bisa nge print chips-chips yang kecil padahal mau di print biar enak nyolderna … 

beikut skript untuk membuat pewaktu .. pake nano dan arduino versi 1.6.8. masih hobi dengan i2c

#include
#include LiquidCrystal_I2C lcd(0x27,16,2);
unsigned long current = 0;
unsigned long previous = 0;
int i;
int minutes = 1;
int seconds = 0;
char buffer[10];
void setup() {
lcd.init();                    
lcd.backlight();
lcd.begin(16, 2);
lcd.print(“One Minute Timer”);
lcd.setCursor(5,1);
sprintf(buffer, “%d:%02d”, minutes, seconds);
lcd.print(buffer);
}
void loop() {
current = millis();
if (current – previous > 1000) {
if (previous == 0){
lcd.setCursor(5,1);
lcd.print(” “);
}
if (seconds == 0 && minutes > 0) {
seconds = 59;
minutes–;
} else {
if (seconds) {
seconds–;
}
}
if (minutes == 0 && seconds == 0) {
warnID();
} else {
lcd.setCursor(6,1);
sprintf(buffer, “%d:%02d”, minutes, seconds);
lcd.print(buffer);
previous = current;
}
}
}

void warnID() {
static bool flag = true;
if (flag) {
current = millis();
if (current – previous > 500) {
lcd.display();
delay(500);
lcd.setCursor(0, 0);
lcd.print(” IDENTIFY “);
lcd.setCursor(0,1);
lcd.print(” NOW “);
flag = false;
}
} else {
delay(500);
lcd.noDisplay();
flag = true;
}
previous = current;
}

Tinggalkan Komentar

Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *

This site uses Akismet to reduce spam. Learn how your comment data is processed.