Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
int RELAY1 = D3;
int RELAY2 = D4;
int RELAY3 = D5;
int RELAY4 = D6;
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);
//register the Particle function
Particle.function("goal", ringTheAlarm);
}
// This loops for ever
void loop()
{
}
int ringTheAlarm(String seconds)
{ int secondsAsInt = atoi(seconds);
if (secondsAsInt < 10 && secondsAsInt > 0) {
int secondsAsSeconds = secondsAsInt * 1000;
digitalWrite(RELAY1, HIGH);
delay(secondsAsSeconds);
digitalWrite(RELAY1, LOW);
return 1;
} else {
digitalWrite(RELAY1, HIGH);
delay(3000);
digitalWrite(RELAY1, LOW);
return 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.