ok so i have everything working wonderfully but i want to accomplish 1 more thing and im not sure how to go about it.
Part one to this question:
under command==“loops” I have a delay() function. I want to be able to sent this time from the dashboard or url.
Example would be… (written in php action of CURL)
$url = “https://api.particle.io/v1/devices/".$my_device."/".$zone_name."?access_token=”.$my_token;
would my url be changed to
$url = “https://api.particle.io/v1/devices/".$my_device."/".$zone_name."?dealy=100&access_token=”.$my_token;
if so how do i asign the var to my delay?
Part 2 of the question is,
I don’t know if delay is the right option. I remember reading something about delay causing a lockout and the device cant do anything while this is going on. If this is the case this will not work as i will have other functions that will trigger other events. What other functions do i have to solve this problem?
int zoneone = D5;
int zonetwo = D6;
int zonethree = D7;
int zonefour = D8;
void setup()
{
// define pine as output high/low not digital read
pinMode(zoneone, OUTPUT);
pinMode(zonetwo, OUTPUT);
pinMode(zonethree, OUTPUT);
pinMode(zonefour, OUTPUT);
// creates the webhook actions
Particle.function("zoneone",zones_one);
Particle.function("zonetwo",zones_two);
Particle.function("zonethree",zones_three);
Particle.function("zonefour",zones_four);
// sets everything to off just to make sure we are in the right state
digitalWrite(zoneone, LOW);
digitalWrite(zonetwo, LOW);
digitalWrite(zonethree, LOW);
digitalWrite(zonefour, LOW);
}
void loop()
{
// Nothing to do here
}
// zone one action
int zones_one(String command) {
if (command=="on") {
digitalWrite(zoneone,HIGH);
return 1;
}
if (command=="loops") {
digitalWrite(zoneone,HIGH);
// need to change this to a delay(var);
delay(75);
digitalWrite(zoneone,LOW);
return 2;
}
else if (command=="off") {
digitalWrite(zoneone,LOW);
return 0;
}
else {
return -1;
}
}
// zone two action
int zones_two(String command) {
if (command=="on") {
digitalWrite(zonetwo,HIGH);
return 1;
}
else if (command=="off") {
digitalWrite(zonetwo,LOW);
return 0;
}
else {
return -1;
}
}
// zone three action
int zones_three(String command) {
if (command=="on") {
digitalWrite(zonethree,HIGH);
return 1;
}
else if (command=="off") {
digitalWrite(zonethree,LOW);
return 0;
}
else {
return -1;
}
}
// zone four action
int zones_four(String command) {
if (command=="on") {
digitalWrite(zonefour,HIGH);
return 1;
}
else if (command=="off") {
digitalWrite(zonefour,LOW);
return 0;
}
else {
return -1;
}
}