Arduino IoT Cloud blinking LED question

Hi, I am following the IoT Cloud guide - getting started and wants to create the blinking LED project.
I believe I have done everything mostly correct, but the LED is not turning on and off as expected.
Any help would be appreciated, thank you.

Here is my code:

/*
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/e95fed4d-e8d7-408b-af8d-9bb05b479a84

  Arduino IoT Cloud Variables description

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

  bool button;

  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 LED_PIN 13;

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  pinMode(LED_BUILTIN, OUTPUT);
  
  // 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 (button){
    Serial.println("on");
    // Do something
    digitalWrite(LED_BUILTIN, HIGH);   
    delay(2000);                       
    digitalWrite(LED_BUILTIN, LOW);    
    delay(2000); 
  }
  
  
}



void onButtonChange() {
  Serial.println("a change has occured");
}


and here is a picture of my switch, the status is just to show that it is linked to the variable correctly:


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