Led using bolt python

I type the above code in ubuntu server and the led blinks for fraction of a sec and then stops blinking.
As the digitalWrite function sets the value of pin ‘0’ to HIGH , it should remain high till the program is running.
Why does it blink and stops immediately??
Can anybody help me out with this??

Hello @chakitbhandari93
Are you connect resister with the LED ?
If voltage more than 3.3V than LED will burn .
Hope this information is useful for you :+1:

@chakitbhandari93 It is happenning because you have not given timer function (time.sleep). If you have completed the course, you would have come across it. If not, then after sometime you will get there eventually.

Hi @chakitbhandari93.

Can you elaborate on your issue? Did this issue repeat for you every time you run the code? If yes, troubleshoot the connections by doing the following: -

  1. Check the connections and make sure the positive end of the LED (Longer end) is connected to pin 0.
  2. Make sure to connect the 330 ohms resistor (The one with orange-orange-brown-gold colour combination) to one of the ends to the LED and connect the other end of the resistor to the pin in the bolt module in series.
  3. Try replacing the LED, probably the one you’re using is burned out.

It will be helpful if you can send a picture/ video of the issue.

And please hide the API key and Device ID while sending the screenshot of the code.

Also, to answer to @akshaykumar.kumar198’s suggestion, using a program hold will not work since the code will only trigger the LED on. The time.sleep() function will be useful only in a loop.

Hope this helps.

@b.utkarsh Fortunately, time.sleep function is used in the loop. I did not suggest timer function without loop. I said he will get there eventually as he progresses with the course. I have been there with the same situation where LEd would glow for a fraction of seconds. There is no problem with LED or led connection or the resistor. If not time.sleep function then at least @chakitbhandari93 needs to declare a state of the LED so that LED remains ON.

@chakitbhandari93 Do not worry, your problem is petite. People tend to exaggerate problems. You will be able to solve your problem soon. Keep going with the course.

Hi @akshaykumar.kumar198.

What I meant was that the time.sleep function won’t be any help since when you just execute the code as @chakitbhandari93 wrote, the LED is supposed to turn on and remain ON.

I did try the exact code that @chakitbhandari93 used to turn the LED using my bolt device, and it worked as required. That’s why I felt that there is an issue with the connection or with the components.

In no way, I was trying to exaggerate the issue here. I know the problem is trivial, I just suggested some ways to see where the problem is coming from, because I fused one of the LED’s during the start of the course since I didn’t connect the resistor with the LED.

If you think otherwise, feel free to reply.

1 Like

Hi @chakitbhandari93

Dont share your API Key and Device Id, anyone can
access your device if you post it open. Kindly cover it.

Thank you

1 Like

You are facing that issue since the command is not inside a loop.
Solution: Try using a while loop.
Also, time.sleep() function can be used to keep the LED ON.
eg: Including time.sleep(10) will keep your LED ON for 10 seconds.

Ya Thank you ,I am moving on

I am sorry I wanted to send this to someone else but i ain’t able to delete it.

Ya I understood but i am facing the same problem again and again

Ya sure THANK YOU @phaniraghavendra661

Ya But,When i execute the code once it should remain ON irrespective of giving the time.sleep() function??
Why do I need to declare time.sleep() function s i have declared the state of LED as HIGH in digitalwrite function.??

@chakitbhandari93 It is called switch bounce. Google it if you want more info on this. So to avoid it we use time.sleep() function or declare a variable to hold the state of the LED.
I do not know how it is done otherwise as stated by @b.utkarsh. You better ask him how he did it because I no longer have access to ubuntu server to verify it.
Or else just use the program given in the course with predefined variable “response” which keeps the led in ON state.


Have you created any product on Bolt cloud that is reading values on this pin? As the Bolt module reads the value of the pin, the LED will turn off.

Also, please check if there is any of your script running in the background that is turning the LED off. This is one of the reasons why the students face such an issue.

You can control another pin (eg pin 4) and connect the LED to it and check if you are facing the same issue.

1 Like

Thank you Sir
Now I am able to get the required output
But, I have a doubt sir
There was some product in the background where I had set pin 0 as HIGH but, until and unless i don’t click on deploy configuration icon the LED shouldn’t turn on ??
As the product is just linked to the device but I haven’t clicked on deployed configuration. Then how’s it receving the signal I am not transmitting??
Can you please answer @yeshwant.naik ??

Hi @chakitbhandari93,

After sending any data points to the Bolt cloud, Bolt device also receives the updated product setting. Also if there is no sensor is connected to the pin, then it will start collecting the garbage data.

Do let me know in case you need any other information.