Hey everyone,
Ive just started with arduino and am slowly getting my head around it, im currently trying to build a Fishtank controller that is automated with a manual switch that can be pressed to enable feeding.
Now i have the basics in place, the switch works and activates the feeding cycle, but i am struggling to find any readup on how to program an RTC, what i want it to do is at X time turn on the lights and at x time turn them off, but then i also need this for the other relays as well.
Heres my current sketch -
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
// RELAYS
int pumprelay = 3;
int filterrelay = 4;
int lightsrelay = 5;
int heaterrelay =6;
//BUTTONS
int FeedingButton = 7;
int HeaterButton = 18;
//LEDS
int lightsled = 8;
int pumpled = 9;
int filterled = 10;
int FeedingLED = 11;
int heaterled = 12;
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(lightsrelay, OUTPUT);
pinMode(lightsled, OUTPUT);
pinMode(heaterrelay, OUTPUT);
pinMode(heaterled, OUTPUT);
pinMode(pumprelay, OUTPUT);
pinMode(pumpled, OUTPUT);
pinMode(filterrelay, OUTPUT);
pinMode(filterled, OUTPUT);
pinMode(FeedingButton, INPUT);
pinMode(FeedingLED, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(FeedingButton);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// Start Feeding Cyle
Feeding();
}
else {
// Continue Normal Program
}
}
void Feeding() {
digitalWrite(FeedingLED, HIGH); // Set Feeding LED On
LightsOn();
PumpOff();
FilterOff();
delay(600000);
digitalWrite(FeedingLED, LOW); // Set Feeding LED Off
LightsOff();
PumpOn();
FilterOn();
delay(1000);
}
void LightsOn() {
digitalWrite(lightsrelay, HIGH); // Set Lights On
digitalWrite(lightsled, HIGH); // Set LED On
}
void LightsOff() {
digitalWrite(lightsrelay, LOW); // Set Lights Off
digitalWrite(lightsled, LOW); // Set LED Off
}
void PumpOn() {
digitalWrite(pumprelay, HIGH); // Set Pump On
digitalWrite(pumpled, HIGH); // Set LED On
}
void PumpOff() {
digitalWrite(pumprelay, LOW); // Set Pump Off
digitalWrite(pumpled, LOW); // Set LED Off
}
void FilterOn() {
digitalWrite(filterrelay, HIGH); // Set Filter On
digitalWrite(filterled, HIGH); // Set LED On
}
void FilterOff() {
digitalWrite(filterrelay, LOW); // Set Filter Off
digitalWrite(filterled, LOW); // Set LED Off
}
Anyone know of any really good guides for RTC at all ?