Script in controlling LED


#1

Sir I am not able to understand this code.
Kindly explain it in detail.


#2

I will require some more context to help you:

  1. What is your objective in writing this code? Are you just trying to learn how to glow an LED or you are looking for something else?
  2. What is the objective of the code? It looks like it is trying to do lot more then just glow one LED.
  3. From where have you taken this code? Knowing the source will help us understand the context better.

#3

@arorasimran006 The code what you have shared is just a JS code to send a remote API call to do a DigitalWrite operation for your Bolt device.
Any context for the code will be really helpful.


#4

Here are my answers:

  1. It is just for the learning purpose.
  2. controlling the LED
  3. Code already exist in the home automation project-3 training module

#5

Sir i am not able to comprehend the code present in the home automation section controlling Led.


#6

@arorasimran006 I suggest you read and complete the project 1 given here: https://docs.boltiot.com/docs/so-what-is-bolt-iot

Note: Read all the points carefully and do NOT skip any sentence or task. Also, if you have the components for project 2 then complete that as well. Let me know once done.


#7

sir i am not able to understand the code which is present in this link in the home automation section https://cloud.boltiot.com/static/js/boltCommands.js . Kindly explain it line by line.


#8

@arorasimran006
The code that you are trying to understand is our internal JavaSript library which uses Ajax calls and APIs.

We have tried to separate the complex code implementations and added them to the JS.

The library exposes functions to the users like digitalWrite, analogRead which you can directly use to control the device.

Since it is a source code, we won’t be able to explain the code line by line. We can definitely help you out with any specific line of code that you are stuck with.

Since the code is a bit complex to understand for a newbie, i would suggest you to refer below blog to understand the basic concepts first.

https://www.w3schools.com/xml/ajax_xmlhttprequest_send.asp