Create your first object connected to the Cloud

Let’s connect the thing

Add a “System.Http” reference to the Gadgeteer project.
Make the following modification to the existing code:
– Declare variables for the connection state, the Timer and the web server URL
– Initialize the network adpater
– Create a Timer to execute code at regular interval.
When the network adpater network address change, update the status of the connection.
Each time the timer event is fired, we create a web API call to get the desired state of the LED.
When the button is pushed, we make an web API call to update the state of the LED on the server.
Add a “LightOn” property. Each time we change its value, the LED module is updated

Congratulation, you made it \o/ Open the web site on any smartphone, tablet or PC. The Switch button should light on/off your device .

Your project should look like this.

For those who want to go a little further and enhance this very simplistic example, I’ll give you some improvement ideas.

2 thoughts on “Create your first object connected to the Cloud

  1. Koenigs

    Hello, it’s the first time I see something like:
    LightOn = s == “true”;
    What does that do exactly? Does this coding trick has a name? (in order to search for it on Google…)?
    Thank you

    1. Alex Danvy Post author

      Hi, this code means that LightOn will get the boolean result of s equal the string “true”. I could have write it like this
      LightOn = s == “true” ? true : false;
      if (s == “true”) {
      LightOn = true;
      } else {
      LightOn = false;


Leave a Reply

Your email address will not be published. Required fields are marked *