Led program led not blinking

 <!doctype html>
<html>
<head>
<title>BOLT</title>
</head>
<body>
<center>
<h3> LED Controller</h3> <br>
<button><a href="digitalWrite?pin=0&state=HIGH">LED ON</a></button><br><br>
<button><a href="digitalWrite?pin=0&state=LOW">LED OFF</a></button>
</center>
</body>
</html>

in this program led cant be controlled

which browser are you using to do this? Try chrome browser

In the program , code has to began with
!DOCTYPE html inside the angular brackets.
Rewrite the code and check it once again , so that the LED can be controlled.
Good day!

Hi @karthikkrishnan.mec:

Where are you running this code from? Are you running it from the product code or from your computer?

In either case, the href that you have used is wrong.
Your href needs to look something like the following

remote/{{ApiKey}}/digitalWrite?pin=0&state=HIGH

This is if you are running the code from the product code configs.

If you are running this code from your own computer, ie you have written this code in a file stored on yoru computer, your href will need to look like the below

cloud.boltiot.com/remote/<api_key>/digitalWrite?pin=0&state=HIGH

Where you will have to replace the tag <api_key> with your Bolt Cloud API key. You can get your api key by clicking on the copy button available in the page given by the link below. (You will need to be logged in to the Bolt Cloud)
https://cloud.boltiot.com/api_credentials

I altered the program a bit to add BLINK button. Except the blink button the remaining two buttons ON and OFF are working.
Here is the altered program, can I know what’s wrong with this?
NOTE: I couldn’t show the whole program directly,so I have placed some single quotes in the tags and please consider them.

<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="digitalWrite(0, 'HIGH');">ON
<button onclick="digitalWrite(0, 'LOW');">OFF
<button onclick="led_blink()">BLINK
</center>
<script>
function led_blink(){
var c=0;
while(c<5){
setTimeout(function(){digitalWrite(0, 'HIGH');},1000);
setTimeout(function(){digitalWrite(0, 'LOW');},1000);
}
}
</script>
</body>
</html>
Bolt IoT Platform
    setKey('API key','Led_Blinks');
    </script>
</head>
<body>
    <center>
    <button onclick="digitalWrite(0, 'HIGH');">ON</button>
    <button onclick="digitalWrite(0, 'LOW');">OFF</button>
    </center>
</body>

What is wrong in this code? I am unable to perform the desired function

Hi @guptamayank0912,

In setKey function, pass API key and device id parameter as below. ApiKey and Name will be auto initialized by bolt cloud.

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

You can check the sample code here https://github.com/Inventrom/ui-templates/blob/master/Led%20Control/test_bulb.html

<html>
<head>
  <!-- In following  line will load the boltCommands.js files from Bolt cloud.-->
  <script type="text/javascript" src="https://cloud.boltiot.com/static/js/boltCommands.js">
  </script>

  <script type="text/javascript">
    // The following line will set the api key and device name. It will be auto-initialized by Bolt cloud.
    setKey('{{ApiKey}}','{{Name}}');
</script>

</head>
<body>
<center>
  <!-- In below line, We are calling the digitalWrite function from  boltCommands.js file to switch on the LED. -->
  <button onclick="digitalWrite(0, 'HIGH');">ON</button>

  <!-- In below line, we are calling the digitalWrite function from boltCommands.js file to switch off the LED. -->
  <button onclick="digitalWrite(0, 'LOW');">OFF</button>

</center>
</body>
</html>

Please check all the connections of the circuit ,make sure you connect the circuit before you turn on the circuit to avoid shorting which leads to damage , please check the software code you have typed , use this below Javascript code for reference