How to get Google home to read output

Hi. I have hacked a sunscreen remote, and created a cloud variable switch up and down.
The code gives a pulse signal High, then goes low. The problem is that the google cloud switch doesn't show that it switches back to low. It's always on after pushing it. I have to turn it off to turn it on again. Is there any way to have google read the actuall output itself?
Here's my code. Sorry if Newbie and English is my second language.

#include "thingProperties.h"
void setup() {
  Serial.begin(9600);
  delay(1500); 
  pinMode(1,OUTPUT);
  pinMode(2,OUTPUT);
  initProperties();
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}
void loop() {
  ArduinoCloud.update();  
}
void onUpChange()  {
 if(up==true)
  {digitalWrite(1,HIGH);}
  delay(500);
  {digitalWrite(1,LOW);}
}
void onDownChange()  {
if(down==true)
  {digitalWrite(2,HIGH);}
  delay(500);
  {digitalWrite(2,LOW);}
}

Hi!
digitalWrite() only acts on physical hardware.
So your code, when receive a cloud event (onUpChange with up == true), perform the physical switch but does not change status back to cloud.
If you want to turn down, you should change 'up' variable value to false after the operation on pins.
Or you can also use a single variable like 'remoteSwitch' using a switch type and do a if/else logic.

Thanks.

Something like this?

void onUpChange()  {
 if(up==true)
  {digitalWrite(1,HIGH);}
  delay(500);
  {digitalWrite(1,LOW);}
up==false;
}

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