Bhavikkumar jogani
Published

Home appliances control with Indicator button using Bolt IoT

This project is mainly concentrated on the button called an indicator button which can be used in Home Automation.

IntermediateProtip2 hours409
Home appliances control with Indicator button using Bolt IoT

Things used in this project

Story

Read more

Schematics

Circuit diagram

Code

Code

HTML
Code for Indicator button
 <html>
<head>
    <h1> <center> Appliences control for Home Automation with real time status button using BOLT-IoT  </center> </h1>
    <style>
        .OFF {
            background-color: #555555;
            border: none;
            color: white;
            padding: 15px 32px;
            text-align: center;
            text-decoration: none;
            display: block;
            font-size: 16px;
            margin: 4px 2px;
            cursor: pointer;
            border-radius: 12px;
        }

        .fan {
            background-color: #008CBA;
            border: none;
            color: white;
            padding: 15px 32px;
            text-align: center;
            text-decoration: none;
            display: block;
            font-size: 16px;
            margin: 4px 2px;
            cursor: pointer;
            border-radius: 12px;
        }

        .light {
            background-color: #4CAF50;
            border: none;
            color: white;
            padding: 15px 32px;
            text-align: center;
            text-decoration: none;
            display: block;
            font-size: 16px;
            margin: 4px 2px;
            cursor: pointer;
            border-radius: 12px;
        }

        .AC {
            background-color: #00ffff;
            border: none;
            color: black;
            padding: 15px 32px;
            text-align: center;
            text-decoration: none;
            display: block;
            font-size: 16px;
            margin: 4px 2px;
            cursor: pointer;
            border-radius: 12px;
        }

        .TV {
            background-color: #f44336;
            border: none;
            color: white;
            padding: 15px 32px;
            text-align: center;
            text-decoration: none;
            display: block;
            font-size: 16px;
            margin: 4px 2px;
            cursor: pointer;
            border-radius: 12px;
        }
    </style>

    <script type="text/javascript" src="https://cloud.boltiot.com/static/js/boltCommands.js">
    </script>

    <script type="text/javascript">

    setKey('{{ApiKey}}','{{Name}}');
    setDebug(false);

    function OFF()
    {
    var elem = document.getElementById("btn1");
     if (elem.value=="OFF")
      {
        digitalWrite(1,'HIGH');
      digitalWrite(2,'HIGH');
      digitalWrite(3,'HIGH');
      digitalWrite(4,'HIGH');
     
        elem.value = "ALL OFF";

        var elem = document.getElementById("btn2").value = "ON";
        var elem = document.getElementById("btn3").value = "ON";
        var elem = document.getElementById("btn4").value = "ON";
        var elem = document.getElementById("btn5").value = "ON"; 
      }
   else
     { 
        elem.value = "OFF";
      digitalWrite(1,'HIGH');
      digitalWrite(2,'HIGH');
      digitalWrite(3,'HIGH');
      digitalWrite(4,'HIGH');
        
      }


    }
    function fan()
    {
    var elem = document.getElementById("btn2");
    if (elem.value=="ON")
    {digitalWrite(1,'LOW');
       elem.value = "OFF";
     }
    else
      { elem.value = "ON"
        digitalWrite(1,'HIGH');
      }
    }
     function light()
      {
    var elem = document.getElementById("btn3");
    if (elem.value=="ON")
    {digitalWrite(2,'LOW');
       elem.value = "OFF";}
    else
      { elem.value = "ON"
        digitalWrite(2,'HIGH');
      }
    }
    function AC() {
    var elem = document.getElementById("btn4");
    if (elem.value=="ON")
    {digitalWrite(3,'LOW');
       elem.value = "OFF";}
    else
      { elem.value = "ON"
        digitalWrite(3,'HIGH');
      }
    }

    function TV() {
    var elem = document.getElementById("btn5");
    if (elem.value=="ON")
    {digitalWrite(4,'LOW');
       elem.value = "OFF";}
    else
      { elem.value = "ON"
        digitalWrite(4,'HIGH');
      }
    }

    </script>
    
    <div class="background">
        <center>

            <h2> <center> Press this button to switch off all the appliences </center> </h2>

            <input type="button" id="btn1" value="OFF" class="OFF" onClick='OFF()' />

            <h3> <center> Fan control</center> </h3>
            <input type="button" id="btn2" value="ON" class="fan" onClick='fan()' />
            <h3> <center> light control </center> </h3>
            <input type="button" id="btn3" value="ON" class="light" onClick='light()' />
            <h3> <center> AC control</center> </h3>
            <input type="button" id="btn4" value="ON" class="AC" onClick='AC()' />
            <h3> <center> TV control </center> </h3>
            <input type="button" id="btn5" value="ON" class="TV" onClick='TV()' />

        </center>

    </div>
</body>
</html>

Credits

Bhavikkumar jogani

Bhavikkumar jogani

1 project • 0 followers

Comments