Hi
I am trying to make a dosing sketch for my aquarium. My issue is as follows:
Choose a set programme. I have a 2dose/day, 4dose/day, 8dose/day, 16dose/day and a 24dose/day. An allocated time has been set for each dose so it corresponds with time.
In order to not write thousands of lines of code I have tried to use arrays.
The first part of the code is to create my 5 arrays of the ON times of the dosing pump.
unsigned long 2Dose[2] = {0, 43200000};
unsigned long 4Dose[4] = {0, 21600000, 43200000, 64800000};
unsigned long 8Dose[8] = {0, 10800000, 21600000, 32400000, 43200000, 54000000, 64800000, 75600000};
unsigned long 16Dose[16] = {0, 5400000, 10800000, 16200000, 21600000, 27000000, 32400000, 37800000,
43200000, 48600000, 54000000, 59400000, 64800000, 70200000, 75600000, 81000000};
unsigned long 24Dose[24] = {0, 3600000, 7200000, 10800000, 14400000, 18000000, 21600000, 25200000, 28800000,
32400000, 36000000, 39600000, 43200000, 46800000, 50400000, 54000000, 57600000,
61200000, 64800000, 68400000, 72000000, 75600000, 79200000, 82800000};
unsigned long OffSet = 300000; //5MINUTE OFFSET
The second part was to create a generic function for the dosing pump
void Run2Dose (int pin,
unsigned long time, //Current time in millis
unsigned long offset, //Offset time in millis avoid clashing of dosing
unsigned long start[], //Start time in millis
unsigned long period) //On period time in millis
{
for (int x = 0; x < 2; x++)
{
if ((time + offset) + start[x] <= (time + offset) + start[x] + period)
{
digitalWrite(pin, HIGH);
}
else if ((time + offset) + start[x] >= (time + offset) + start[x] + period)
{
digitalWrite(pin, LOW);
}
}
}
void Run4Dose (int pin,
unsigned long time, //Current time in millis
unsigned long offset, //Offset time in millis avoid clashing of dosing
unsigned long start[], //Start time in millis
unsigned long period) //On period time in millis
{
for (int x = 0; x < 4; x++)
{
if ((time + offset) + start[x] <= (time + offset) + start[x] + period)
{
digitalWrite(pin, HIGH);
}
else if ((time + offset) + start[x] >= (time + offset) + start[x] + period)
{
digitalWrite(pin, LOW);
}
}
}
void Run8Dose (int pin,
unsigned long time, //Current time in millis
unsigned long offset, //Offset time in millis avoid clashing of dosing
unsigned long start[], //Start time in millis
unsigned long period) //On period time in millis
{
for (int x = 0; x < 8; x++)
{
if ((time + offset) + start[x] <= (time + offset) + start[x] + period)
{
digitalWrite(pin, HIGH);
}
else if ((time + offset) + start[x] >= (time + offset) + start[x] + period)
{
digitalWrite(pin, LOW);
}
}
}
void Run16Dose (int pin,
unsigned long time, //Current time in millis
unsigned long offset, //Offset time in millis avoid clashing of dosing
unsigned long start[], //Start time in millis
unsigned long period) //On period time in millis
{
for (int x = 0; x < 16; x++)
{
if ((time + offset) + start[x] <= (time + offset) + start[x] + period)
{
digitalWrite(pin, HIGH);
}
else if ((time + offset) + start[x] >= (time + offset) + start[x] + period)
{
digitalWrite(pin, LOW);
}
}
}
void Run24Dose (int pin,
unsigned long time, //Current time in millis
unsigned long offset, //Offset time in millis avoid clashing of dosing
unsigned long start[], //Start time in millis
unsigned long period) //On period time in millis
{
for (int x = 0; x < 24; x++)
{
if ((time + offset) + start[x] <= (time + offset) + start[x] + period)
{
digitalWrite(pin, HIGH);
}
else if ((time + offset) + start[x] >= (time + offset) + start[x] + period)
{
digitalWrite(pin, LOW);
}
}
}
And the last part is the actual function
void RunDosers()
{
ActualTime = (((hour()*3600) + (minute()*60) + second()) * 1000);
if (Doser1Prog == 4)
{
for (int x = 0; x < 2; x++)
Run2Dose(DOS1, ActualTime, 0, 2Dose[x], D1P2); //pin/time/ offset/start[]/period
if (DOS1 == HIGH)
{
LEDDOSER1.setColor(Blue);
LEDDOSER1.on();
}
else if (DOS1 == LOW)
{
LEDDOSER1.setColor(Green);
LEDDOSER1.on();
}
}
else if (Doser1Prog == 5)
{
for (int x = 0; x < 4; x++)
Run4Dose(DOS1, ActualTime, OffSet, 4Dose[x], D1P4); //pin/time/ offset/start[]/period
if (DOS1 == HIGH)
{
LEDDOSER1.setColor(Blue);
LEDDOSER1.on();
}
else if (DOS1 == LOW)
{
LEDDOSER1.setColor(Green);
LEDDOSER1.on();
}
}
else if (Doser1Prog == 6)
{
for (int x = 0; x < 8; x++)
Run8Dose(DOS1, ActualTime, (OffSet * 2), 8Dose[x], D1P8); //pin/time/ offset/start[]/period
if (DOS1 == HIGH)
{
LEDDOSER1.setColor(Blue);
LEDDOSER1.on();
}
else if (DOS1 == LOW)
{
LEDDOSER1.setColor(Green);
LEDDOSER1.on();
}
}
else if (Doser1Prog == 7)
{
for (int x = 0; x < 16; x++)
Run16Dose(DOS1, ActualTime, (OffSet * 3), 16Dose[x], D1P16); //pin/time/ offset/start[]/period
if (DOS1 == HIGH)
{
LEDDOSER1.setColor(Blue);
LEDDOSER1.on();
}
else if (DOS1 == LOW)
{
LEDDOSER1.setColor(Green);
LEDDOSER1.on();
}
}
else if (Doser1Prog == 8)
{
for (int x = 0; x < 24; x++)
Run24Dose(DOS1, ActualTime, (OffSet * 4), 24Dose[x], D1P24); //pin/time/ offset/start[]/period
if (DOS1 == HIGH)
{
LEDDOSER1.setColor(Blue);
LEDDOSER1.on();
}
else if (DOS1 == LOW)
{
LEDDOSER1.setColor(Green);
LEDDOSER1.on();
}
}
}
The issue is it does not compile. The following is the compile error
C:\Users\proie\Dropbox\ARDUINO\arduino 1.8.9\AquArt_Blynk_DoserTest\DOSERS.ino: In function 'void RunDosers()':
DOSERS:218:35: error: unable to find numeric literal operator 'operator"" Dose'
Run2Dose(DOS1, ActualTime, 0, 2Dose[x], D1P2); //pin/time/ offset/start[]/period
^
DOSERS:233:40: error: unable to find numeric literal operator 'operator"" Dose'
Run4Dose(DOS1, ActualTime, OffSet, 4Dose[x], D1P4); //pin/time/ offset/start[]/period
^
DOSERS:248:46: error: unable to find numeric literal operator 'operator"" Dose'
Run8Dose(DOS1, ActualTime, (OffSet * 2), 8Dose[x], D1P8); //pin/time/ offset/start[]/period
^
DOSERS:263:47: error: unable to find numeric literal operator 'operator"" Dose'
Run16Dose(DOS1, ActualTime, (OffSet * 3), 16Dose[x], D1P16); //pin/time/ offset/start[]/period
^
DOSERS:278:47: error: unable to find numeric literal operator 'operator"" Dose'
Run24Dose(DOS1, ActualTime, (OffSet * 4), 24Dose[x], D1P24); //pin/time/ offset/start[]/period
^
exit status 1
expected unqualified-id before numeric constant
can somebody please point me as to where I am going wrong please.
Thanks