LED Control about the pin and api key

I want to know why are we taking digital pin 0 in led and why are considering API key here through html?
And in javascript what is analogwrite and read functions are that also turning led on and off?

We use GPIO pins (0,1,2,3,4) to connect Input or Output devices
API key is used to identify that you have send a request
The analogWrite is mainly used to update the status of analog pins and is also used to map the analog values on the [PWM (Pulse Width Modulation) you can set it between 0-255

Hope you got the answer

Mark solution if helpful

1 ans)we know,the LED is the output device & in bold device we can take the 1 pin.
that is 0 pin.because,in bolt device have the 5 GPIO(general purpose input output)pins for giving the output we use the 0 pin.the API is used to make a contact with your bolt device to web page.we can be control the LED through mobile phone by using API.

2 ans)sorry,in javascript i don’t use analogwrite.i have only use in js is src,api,name.In body tag i have use digitalwrite for the cause of control the led with 1’s & 0’s.

@swastishree10 , I am sure you are talking about the LED Controller project in the Home Automation Section. So let us go through the HTML way and the javaScript way of implementing the project.
A. HTML Way: In the HTML code of the project you can find that there we have to include an external javaScript file that is https://cloud.boltiot.com/static/js/boltCommands.js. In this file, the BOLT’s team has used the javaScript language to implement the basic functions like the GPIO functions (analogRead, digitalWrite and so on), UART functions (serialBegin and others). So bascially by using this js file, at the end our command is going out in the form of an API request. The basic syntax of an API request made to the Bolt Cloud is as follows: https://cloud.boltiot.com/remote/API_KEY/command_name?parameters&device_ID
So in this way through this API request, the cloud gets to know that which bolt cloud device is making the request and what are the commands which have to be executed.

Say, you wrote a HTML code for the analogRead function then the request will be as follows https://cloud.boltiot.com/remote/API_KEY/analogRead?pin=A0&deviceName=device_ID

This is the reason you have to provide the API key and device id in the HTML code. Below is a snippet of the js file which has to be included in the HTML code.


You can see that your API_KEY and device_id are required to send a correct request to the cloud.

B. JS Way: When we use the javaScript to write the code, we are already provided with a function named singleButton which has different key-value pairs attached to it. It doesn’t have to send the commands over the cloud in form of API requests. The team has internally configured this function in such a way that the commands and their values will be extracted and will be locally send to the bolt device which will be connected to the machine.

Hope this helps you to understand the difference :slight_smile:

2 Likes

thank you @vishalvats2000

Your welcome, @swastishree10

tq @pathansaifalikhan840