Led button control


#1

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


#2

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)?


#3

i am trying to control led brightness on cloud


#4

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