Led button control

i have typed the same code but i am getting an error for making a button for led control

This doesn’t look like the required code. Are you trying to simply control led brightness on Cloud?
OR Are you trying to control LED using VPS(Digital Ocean/ VMWare)?

i am trying to control led brightness on cloud

Then you should be creating a HTML file rather than JS
Where did you get this code from…

If I’m not wrong this is what you want…

<!DOCTYPE html>
<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}}');
        </script>
    </head>
    <body>
        <center>
        <button onclick="analogWrite(0, 20);">ON</button>  
        <button onclick="analogWrite(0, 160);">OFF</button>
        </center>
    </body>
</html>

LED Brigthness ranges from 0 to 255

If you wish to add a slider that would toggle the brightness.
Check this out