So I have the program written to control the relay shield the way I want. Now I’d like to be able to control the time variables via a web page. The problem is, I honestly have no clue what I’m doing. I understand parts of code, but that’s about it.
The project I’m working on is a two channel peristaltic dosing pump to pump additives into my coral reef aquarium. Some times the amount of the additives needs to change based on the aquariums needs and I’d like to be able to easily change the dosing times.
Is it too much to ask for someone to help me port this over to be web accessible?
Here is the code:
// This #include statement was automatically added by the Spark IDE.
#include "SparkTime.h"
UDP UDPClient;
SparkTime rtc;
int RELAY1 = D0;
int RELAY2 = D1;
int RELAY3 = D2;
int RELAY4 = D3;
void setup()
{
//Initilize the relay control pins as output
pinMode(RELAY1, OUTPUT);
pinMode(RELAY2, OUTPUT);
pinMode(RELAY3, OUTPUT);
pinMode(RELAY4, OUTPUT);
// Initialize all relays to an OFF state
digitalWrite(RELAY1, LOW);
digitalWrite(RELAY2, LOW);
digitalWrite(RELAY3, LOW);
digitalWrite(RELAY4, LOW);
rtc.begin(&UDPClient, "pool.ntp.org");
rtc.setTimeZone(-5); // gmt offset
rtc.setUseDST(true);
}
void loop() {
unsigned long currentTime = rtc.now();
static unsigned long stopTime = 0;
if (rtc.hour(currentTime)==0 && rtc.minute(currentTime)==17 && rtc.second(currentTime)==00) {
digitalWrite(RELAY1,HIGH);
stopTime = currentTime + (2); //one minute and ten seconds
}
if (currentTime >= stopTime) {
digitalWrite(RELAY1,LOW);
}
if (rtc.hour(currentTime)==0 && rtc.minute(currentTime)==17 && rtc.second(currentTime)==03) {
digitalWrite(RELAY2,HIGH);
stopTime = currentTime + (2); //one minute and ten seconds
}
if (currentTime >= stopTime) {
digitalWrite(RELAY2,LOW);
}
delay(100);
}