Program Pakan Otomatis.docx

  • Uploaded by: Agus Triwahyudin
  • 0
  • 0
  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Program Pakan Otomatis.docx as PDF for free.

More details

  • Words: 390
  • Pages: 5
/* * Mengontrol Servo dengan Sensor Ultrasonic * Email : [email protected] * www.boarduino.blogspot.com */

// Arduino Uno/2009: // ---------------------// DS3231: SDA pin -> Arduino Analog 4 or the dedicated SDA pin //

SCL pin -> Arduino Analog 5 or the dedicated SCL pin

// // Arduino Leonardo: // ---------------------// DS3231: SDA pin -> Arduino Digital 2 or the dedicated SDA pin //

SCL pin -> Arduino Digital 3 or the dedicated SCL pin

// // Arduino Mega: // ---------------------// DS3231: SDA pin -> Arduino Digital 20 (SDA) or the dedicated SDA pin //

SCL pin -> Arduino Digital 21 (SCL) or the dedicated SCL pin

// // Arduino Due: // ---------------------// DS3231: SDA pin -> Arduino Digital 20 (SDA) or the dedicated SDA1 (Digital 70) pin //

SCL pin -> Arduino Digital 21 (SCL) or the dedicated SCL1 (Digital 71) pin

// // The internal pull-up resistors will be activated when using the // hardware I2C interfaces. //

// You can connect the DS3231 to any available pin but if you use any // other than what is described above the library will fall back to // a software-based, TWI-like protocol which will require exclusive access // to the pins used, and you will also have to use appropriate, external // pull-up resistors on the data and clock signals. // http://www.instructables.com/id/Real-time-clock-using-DS3231-EASY/?ALLSTEPS

#include #include #include <Servo.h> #include <Wire.h> #include #include "RTClib.h"

int buzz = 8; RTC_DS1307 rtc; Servo servo; LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // initialise the LCD

void setup() { pinMode(buzz, OUTPUT); Serial.begin (9600); Wire.begin(); servo.attach(13); servo.write(0); rtc.begin(); { Serial.println("RTC is NOT running!"); }

lcd.begin (16, 2); lcd.setBacklightPin(3,POSITIVE); lcd.setBacklight(HIGH); lcd.clear(); lcd.setCursor(0,0); lcd.print("SMART FEEDER"); delay(2000); }

void loop() { DateTime now = rtc.now();

Serial.print(now.year(), DEC); Serial.print('/'); Serial.print(now.month(), DEC); Serial.print('/'); Serial.print(now.day(), DEC); Serial.print('/'); Serial.print(now.hour(), DEC); Serial.print('/'); Serial.print(now.minute(), DEC); Serial.print('/'); Serial.print(now.second(), DEC); Serial.println(); Serial.println(); delay(1000);

lcd.clear(); lcd.setCursor(0,0);

lcd.print(now.year(), DEC); lcd.print('/'); lcd.print(now.month(), DEC); lcd.print('/'); lcd.print(now.day(), DEC); lcd.setCursor(0,1); lcd.print(now.hour(), DEC); lcd.print('/'); lcd.print(now.minute(), DEC); lcd.print('/'); lcd.print(now.second(), DEC);

// Servo ON

if (now.hour() == 2 & now.minute() == 59 & now.second() == 33) { digitalWrite(buzz, HIGH); servo.write(45); delay(3000); servo.write(0); lcd.clear(); lcd.setCursor(0,0); lcd.print("WAKTU MAKAN"); delay(2000); digitalWrite(buzz, LOW); }

// Servo OFF else if (now.hour() == 3 & now.minute() == 00 & now.second() == 10)

{ digitalWrite(buzz, HIGH); servo.write(45); delay(3000); servo.write(0); lcd.clear(); lcd.setCursor(0,0); lcd.print("WAKTU MAKAN"); delay(2000); digitalWrite(buzz, LOW); }

}

Related Documents

Program Pakan Otomatis.docx
November 2019 3
Pakan Harian.docx
May 2020 15
Pakan Feedlot
June 2020 7
Ev-pakan
May 2020 23
Pakan Ayam.docx
May 2020 5
Pakan Epid.docx
November 2019 12

More Documents from ""