Saikeerthana arun
Published

Lazy Lights

Cozily tucked up in your bed, but you forgot to dim the lights? Using Bolt Iot Module and Bolt IOT cloud, you can do this from your bed!

BeginnerFull instructions provided243
Lazy Lights

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
LED (generic)
LED (generic)
×1

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud
Bolt IoT Android App
Bolt IoT Android App

Story

Read more

Custom parts and enclosures

Actual Circuit

The physical circuit.

Schematics

Circuit Diagram

Very basic connection. Longer side(i.e. +ve) to the 0 pin and shorter side of the LED to the GND.

Code

Lazy Lights Code

HTML
The Led intensity can range from 0 to 255, 0 being no light and 255 being the brightest.
Essentially, a slider(range) is to be used by the user to determine the value of brightness, based on the input, we convert it to analog and write it to the output stream.
<html>

    <head>

        <title>Bolt IoT Platform</title>

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

        <script>
        setKey('{{ApiKey}}','{{Name}}');

        var last_pwm_value=-1;
        function updateBuzzer(){
            var pwm_value=document.getElementById('pwm_value').value;
            if(last_pwm_value!=pwm_value){
                analogWrite(0,pwm_value);
                document.getElementById('pwm_value_display').innerHTML=pwm_value;
            }
            last_pwm_value=pwm_value;
        }
        setInterval(updateBuzzer,1000);
        </script>
    </head>
    <body>
        pwm value:
        <input type='range' id='pwm_value' min="0" max="255" value="0">
        <div id='pwm_value_display'>0</div>
    </body>

</html>

Credits

Saikeerthana arun
1 project • 0 followers
Contact

Comments

Please log in or sign up to comment.