hey guys i have some code i want checked so i dont kill all my fish.
I just made this quick so tell me if theres something i should be worried about.
explanation:
so i have 4 dosing pumps the 4th one not being used, but i have it defined in the code.
i am using a RTC to keep time, at 8 30 i have pump one turn on delay 5 seconds, turn off, then 2 second pause, repeat for pump 2 and 3. then a 60 second pause to wait for the minute to change so it does not repeat.
please let me know if any changes should be made, if any of these over dose it could be fatal for my fish.
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 rtc;
int const motor1 = 9;
int const motor2 = 11;
int const motor3 = 12;
int const motor4 = 13;
void setup () {
pinMode(motor1, OUTPUT);
pinMode(motor2, OUTPUT);
pinMode(motor3, OUTPUT);
pinMode(motor4, OUTPUT);
Serial.begin(57600);
#ifdef AVR
Wire.begin();
#else
Wire1.begin(); // Shield I2C pins connect to alt I2C bus on Arduino Due
#endif
rtc.begin();
if (! rtc.isrunning()) {
Serial.println("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
//rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}
}
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();
if( (now.hour() == 8 ) && (now.minute() == 10))
{digitalWrite(motor1, HIGH);
delay(5000);
digitalWrite(motor1, LOW);
delay(2000);
digitalWrite(motor2, HIGH);
delay(5500);
digitalWrite(motor2, LOW);
delay(2000);
digitalWrite(motor3, HIGH);
delay(5000);
digitalWrite(motor3, LOW);
delay(60000);
}
delay(1000);
}