Tutorial Arduino: How to turn on and off a led from a web page while showing the temperature of the room

Scritto da Alessandra De Rosa on . Postato in Formazione, Prodotti, Progetto Leonardo da Vinci, Servizi, Tutorials Arduino

 

This project consists on turning ON and OFF a led from a web page and get the temperature of the room the circuit is in.

We used :

  • 1 Arduino
  • 1 Breadboard
  • 1 Ethernet shield
  • 1 Lm35
  • 1 Led
  • 1 Resistance
  • 1 Rj45

The first part of this tutorial is equal to our last one. Where you have to build a system to turn on and off a led.

This project is based on that one, but with a new interface and a new feature.

The new interface is made by this code:

 client.println("HTTP/1.1 200 OK.....");
        client.println("Content-Type: text/html");
        client.println();
       client.print("<html> <style> table ,th, dt{ border:1px solid black; border-collapse:collapse;}"); // creates the table and costumizes the border for the temperature
       client.println("th, dt {padding:5px;}</style>"); // also border costumization
       client.print("<p><a href='/?L=1'>ACCENDI</a> | <a href='/?L=0'>SPEGNI</a></p>");
       client.println("<table><tr><th>Led status:</th>");
       client.print("<th>");
          if (LEDON) {
              client.println("<span style='color:green; font-weight:bold;'>ON</span></font>");
            }
            else
            {
              client.println("<span style='color:grey; font-weight:bold;'>OFF</span></font>");
          }
      client.print("</th>");
      client.print("<tr><th>Reference Temperature</th>"); client.print("<th></th>");
      client.println("<tr><th>Temperature of the room</th>");
      client.print("<th>");     client.print(x2);   client.println("</th>"); 
        client.println("</body></html>");


Here we just built a different way of showing the on off switch and the status of the led and the temperature.

The sketch for this is :

arduino led temperature sketch

The pictures for this are :

When it’s ON:

arduino led temperature on

When it’s OFF:

arduino led temperature off

 

22 July 2014

Alexandre Leitao

Gonçalo Neto

Google+