/* Program Pemberi Pakan Ikan dengan Aplikasi Blynk */
#include <Servo.h>
Servo myServo; // create a servo object
#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>
#include <Servo.h>
int const potPin = 2; // analog pin used to connect the potentiometer
int potVal; // variable to read the value from the analog pin
int angle; // variable to hold the angle for the servo motor
int jam = 6;
int menit = 0;
void setup() {
myServo.attach(4); // attaches the servo on pin 9 to the servo object
Serial.begin(9600); // open a serial connection to your computer
while (!Serial) ; // wait for serial
delay(200);
Serial.println("DS1307RTC Read Test");
Serial.println("-------------------");
}
void loop() {
potVal = analogRead(potPin); // read the value of the potentiometer
// print out the value to the Serial Monitor
Serial.print("potVal: ");
Serial.print(potVal);
// scale the numbers from the pot
angle = map(potVal, 0, 1023, 0, 179);
// print out the angle for the servo motor
Serial.print(", angle: ");
Serial.println(angle);
// set the servo position
myServo.write(angle);
// wait for the servo to get there
delay(15);
tmElements_t tm;
if (tm.Hour == jam && tm.Minute == menit) {
myservo.write(180);
delay(1000);
}
myservo.write(0);
if (RTC.read(tm)) {
Serial.print("Time = ");
print2digits(tm.Hour);
Serial.write(':');
print2digits(tm.Minute);
Serial.write(':');
print2digits(tm.Second);
}
delay(1000);
}
void print2digits(int number) {
if (number >= 0 && number < 10) {
Serial.write('0');
}
Serial.print(number);
}