IOT Calendar e botão para acionar uma bomba d'água

Boa tarde, pessoal!

Estou tentando fazer um código que ligue uma bomba quando o calendário estiver ativo, mas que também possa ser acionado através de um botão no dashboard. O LED de saída (simulando a bomba) fica piscando a menos que o calendário esteja ativo e o botão apertado, mas não é isso que eu quero.

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/758ca0da-74e6-4361-9014-33d2deb21fff 

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  CloudLight led;
  CloudSwitch switch1;
  CloudSchedule calendar;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"
#define pump 10
#define ferti 11

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500); 
  pinMode(10, OUTPUT);
  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  ArduinoCloud.update();
  if (calendar.isActive()){
    digitalWrite(10, HIGH);
    Serial.println("Calendar activated");
    delay(500);
  } else
  {
    digitalWrite(10, LOW);
    Serial.println("Calendar deactivated");
    delay(500);
  }     
/*if (led == 1){
   digitalWrite(10, HIGH);
   Serial.println("On by button");
   delay(500);
 } else{
   digitalWrite(10, LOW);
   Serial.println("Off by button");
   delay(500);
 }*/
}
void onLedChange()  {
 if (led == 1){
   digitalWrite(10, HIGH);
   Serial.println("On by button");
   delay(500);
 } else{
   digitalWrite(10, LOW);
   Serial.println("Off by button");
   delay(500);
 }
}

void onCalendarChange()  {
  // Add your code here to act upon Calendar change
}


void onSwitch1Change()  {
  
}

Preciso que fique ligado quando o calendário estiver ativo (independente da posição da chave do LED, mas que quando eu mande desligar via botão do led, a bomba desligue. Não sei se fui claro. Segue o dashboard de controle bem simples:

Quem puder ajudar, agradeço.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.