Light Intensity control

Can i use Slider in place of button to control the intensity of light?
How the slider will be encoded?

Slider example
Go to the above link, you will find a good explanation there.

Hi @sakshamthool98,

Try out this code


<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 updateLedIntensity(){
            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(updateLedIntensity,3000);
        </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>``` 

The code will update the intensity of the LED every 3 seconds, so as to ensure that your code does not end up causing your API to be rate limited.