0% found this document useful (0 votes)
13 views5 pages

include

Uploaded by

smpn4 busungbiu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views5 pages

include

Uploaded by

smpn4 busungbiu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

#include <Servo.

h>

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

//RTC

#include "RTClib.h"

RTC_DS3231 rtc;

char dataHari[7][12] = {"Ming", "Senin", "Sel", "Rabu", "Kamis", "Jumat", "Sabtu"};

String hari;

int tanggal, bulan, tahun, jam, menit, detik;

float suhu;

//LCD

#include <LiquidCrystal_I2C.h>

#include <Wire.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);//0x34 //0x27

//HITUNG

int x = 0;

int input = A0;

int state = 0;

//SERVO

const int P8 = 8; //LAMP

const int P9 = 9; //UV

const int P10 = 10; //

const int P11 = 11; //

const int P12 = 12; //

int relayL = LOW; //relay nyala


int relayH = HIGH; //relay mati

void setup () {

//LCD

//lcd.begin();

lcd.backlight();

//MOTOR

//LAMPU

pinMode(P8, OUTPUT); //

pinMode(P9, OUTPUT); // kabelputih

pinMode(P10, OUTPUT); // kabelorange

pinMode(P11, OUTPUT); // kabelhijau

pinMode(P12, OUTPUT); // kabelbiru

digitalWrite(P8, relayH);

digitalWrite(P9, relayH);

digitalWrite(P10, relayH);

digitalWrite(P11, relayH);

digitalWrite(P12, relayH);

//RTC

if (! rtc.begin()) {

Serial.println("RTC Tidak Ditemukan");

Serial.flush();

abort();

}
//Atur Waktu

//rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));

//rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));

void loop ()

//RTC

DateTime now = rtc.now();

hari = dataHari[now.dayOfTheWeek()];

tanggal = now.day(), DEC;

bulan = now.month(), DEC;

tahun = now.year(), DEC;

jam = now.hour(), DEC;

menit = now.minute(), DEC;

detik = now.second(), DEC;

suhu = rtc.getTemperature();

Serial.println(String() + hari + ", ");

Serial.println(String() + tanggal );

Serial.println(String() + "." + bulan);

Serial.println(String() + "." + tahun );

Serial.println(String() + tanggal + "." + bulan + "." + tahun );

Serial.println(String() + jam + ":" + menit + ":" + detik );

Serial.println(String() + suhu );

Serial.println();

//LCD

lcd.setCursor(12, 1);

lcd.print(x);
lcd.print(" ");

lcd.setCursor(0,0);

lcd.print(String() + hari + "_ " + tanggal + "." + bulan + "." + tahun);

lcd.print(" ");

lcd.setCursor(0,1);

lcd.print(String() + jam + ":" + menit + ":" + detik );

lcd.print(" ");

lcd.print(String() + suhu );

//hitung

int counter = digitalRead(A0);

if (state == 0)

switch (counter) {

case 1 : state = 1; lcd.setCursor (0, 1); x = x + 1; lcd.print(x); break;

case 0 : state = 0; break;

if (counter == LOW) {

state = 0;

//KONDISI
//P8

if (menit == 0 & detik == 00 ){

digitalWrite(P8,LOW);

if (menit == 15 & detik == 00){

digitalWrite(P8,HIGH);

//KASI_PAKAN

if (jam == 18 & menit == 00 & detik == 1 ){

kasi_pakan(1);

if (jam == 6 & menit == 30 & detik == 1 ){

kasi_pakan(1);

void kasi_pakan(int jumlah){

for(int i = 0; i <= jumlah; i ++){

digitalWrite(P10,HIGH);

delay(100);

digitalWrite(P10,LOW);

delay(100);

You might also like