I'm trying to turn my Misting_Solenoid_A, HIGH every 5 seconds and then turn it LOW 3 seconds later. I then want it to turn HIGH again 5 seconds after it previously turned LOW, and then turn it LOW once again 3 seconds after that (Loops continuously)
Essentially:
5 seconds into the sketch - Misting_Solenoid_A, HIGH
8 seconds into the sketch - Misting_Solenoid_A, LOW
13 seconds into the sketch - Misting_Solenoid_A, HIGH
16 seconds into the sketch - Misting_Solenoid_A, LOW
(Loops)
I attached a screenshot of my serial monitor to show what my issue is.
Does anyone have any suggestions? I've already studied and tried using the timeAlarms.h example library with no luck.
Thank you very much for your time!
IDE V. 1.8.5
//----------LIBRARIES----------//
#include <TimeLib.h>
#include <TimeAlarms.h>
//----------GLOBAL VARIABLES----------//
const int Misting_Solenoid_A = 13;
//-------------------------//
//----------SETUP----------//
//-------------------------//
void setup()
{
Serial.begin(9600);
setTime(8,29,0,1,1,11); //Set time to Saturday 8:29:00am Jan 1 2011
pinMode(Misting_Solenoid_A, OUTPUT);
digitalWrite(Misting_Solenoid_A, LOW);
Alarm.timerRepeat(5, Misting_Solenoid_On);
}
//------------------------//
//----------LOOP----------//
//------------------------//
void loop()
{
digitalClockDisplay();
Alarm.delay(1000); //Wait one second between clock display
}
//----------FUNCTIONS----------//
//MISTING SOLENOID ON//
void Misting_Solenoid_On()
{
Serial.println("Misting Solenoid A is ON");
digitalWrite(Misting_Solenoid_A, HIGH);
Alarm.timerOnce(3, Misting_Solenoid_Off);
}
//MISTING SOLENOID OFF//
void Misting_Solenoid_Off()
{
Serial.println("Misting Solenoid A is OFF");
digitalWrite(Misting_Solenoid_A, LOW);
}
//DIGITAL CLOCK DISPLAY//
void digitalClockDisplay()
{
// digital clock display of the time
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.println();
}
//PRINT DIGITS//
void printDigits(int digits)
{
Serial.print(":");
if (digits < 10)
Serial.print('0');
Serial.print(digits);
}
