Netplug app in bolt

Boltmatix

LED Brightness Control


ON OFF 100 PWM

i can’t switch the LED on by using netplug app. This is the code,is it right?is anything wrong?

Hi @shaunmorais1998
Please share your code here.First copy the code in the box. Select the code and click on </> symbols from text formatting.

<!DOCTYPE html>
Boltmatix

LED Brightness Control


ON OFF 100 PWM

Hi @shaunmorais1998 ,
Your code is not visible. You can edit your previous reply.Please refer Netplug app in bolt

<!DOCTYPE html>
<html>
<head>
<title> Boltmatix </title>
<script type="text/javascript" src="/serveFile/filename=bolt.js"> setDebug(true), </script> 
<meta name="viewport" content="width=device-width,initial scale=1.0">
</head>
<body>
<center>
<h2> LED Brightness Control </h2><br>
<button onclick="digitalWrite(4,HIGH);">ON</button> 
<button onclick="digitalWrite(4,LOW);">OFF</button> 
<button onclick="analogWrite(4,100);">100 PWM</button>
</center>
</body>
</html>

Hi @shaunmorais1998

Refer this code

<!doctype html> 
<html> 
<head> 
<title>BOLT</title> 
<script type="text/javascript" src="/serveFile?filename=bolt.js">setDebug(true);</script> 
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head> 
<body> 
<center> 
<h3>LED Controller</h3> <br> 
<button onclick="digitalWrite(4,'HIGH');">ON</button> 
<button onclick="digitalWrite(4,'LOW');">OFF</button> 
<button onclick="analogWrite(4,100);">100 PWM</button>
</center> 
</body> 
</html>

1) In your code, the syntax to load files from the bolt is incorrect.
<script type="text/javascript" src="/serveFile/filename=bolt.js"> setDebug(true), </script>
The correct syntax to load any files from Bolt is /serveFile?filename=your_file_ name
For example :
<script type="text/javascript" src="/serveFile?filename=bolt.js">setDebug(true);</script>

2) In Digital Write function, you need to pass a value as a parameter.
In your code <button onclick="digitalWrite(4,HIGH);">ON</button>
HIGH is a varible that is undefined because you have’nt initialized the HIGH variable .
So that correct syntax will be
<button onclick="digitalWrite(4,'HIGH');">ON</button>

You can also refer the source code of bolt.js file https://github.com/Inventrom/bolt-sdcard-files/blob/master/bolt.js

Let me know in case you need further assitance.

It still doesn’t work.I’ve tried using your code but it didn’t work,is there anything wrong in the syntax of button tag?

@shaunmorais1998 ,
Type the bolt _ip in Chrome browser and do console log(Go to View ->Developer -> JavascriptConsole) and check os there is any error or warning message.
Send me the screenshot of your console.

Hi @shaunmorais1998 ,
As you can see in the console that bolt.js file is not found in SD card.
Please download the bolt.js file from https://github.com/Inventrom/bolt-sdcard-files and copy it root of SD card.
Let me know in case you need further assistance.