Buenas tardes, espero puedan ayudarme.
Tengo que encender o apagar un LEd desde arduino IOT cloud y al mismo tiempo con un botón físico en la placa se debe controlar el mismo led.
Este es mi código
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled"
https://create.arduino.cc/cloud/things/05efc352-59d2-4adf-a9eb-eecdd0fa5926
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
bool luz1;
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"
int manualswitch1 = 23;
int salida1= 4;
boolean state1=true;
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(115200);
pinMode(2,OUTPUT);
pinMode(salida1,OUTPUT);
pinMode(manualswitch1,INPUT_PULLUP);
//digitalWrite(salida1,state1);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);
// 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();
// Your code here
if(digitalRead(manualswitch1)==LOW){
Serial.println("ficha pasada");
luz1=!luz1;
void onLuz1Change();
delay(500);
while(digitalRead(manualswitch1)==LOW){}
}
}
/*
Since Luz1 is READ_WRITE variable, onLuz1Change() is
executed every time a new value is received from IoT Cloud.
*/
void onLuz1Change() {
// Add your code here to act upon Luz1 change
digitalWrite(salida1,state1);
state1= !state1;
Serial.println("ficha cancelada");
}
El problema que tengo es que desde la aplicación se controla normalmente pero no reacciona al botón, espero puedan ayudarme