Hi Team,
I have a very simple project going on. Controlling 2 GPIO’s on/off;
I tried 2 different programs and the observation is same in both.
when i command a gpio to go high ; it goes high on button click and after uncertain time(seconds) it turns off.
I am attaching my both the programs.
1.: in html
<!DOCTYPE html>
<html>
<head>
<title>LED_Switch</title>
</head>
<body bgcolor = "#446173" text ="#ffffff">
<script type="text/javascript" src="https://cloud.boltiot.com/static/js/boltCommands.js"></script>
<script>
setKey('{{ApiKey}}','{{Name}}');
</script>
<div style="position:absolute ; top:10px; width: 200px; height: 20px; "><a href="https://robobuddies.blogspot.com/#!/" target="_blank">
<button onclick = "start_timer()">Visit my blog</button></a></div>
<div><button style="position:absolute ; ;top:70px; left:10px;width: 100px; height: 50px;background-color:#202630;" onclick="run(1);">
<font color="green" size="5">ON_1</font></button></div>
<div><button style="position:absolute ; top:70px; left:110px;width: 100px; height: 50px; background-color:#202630;" onclick="stop(1);">
<font color="red" size="5">OFF_1</font></button></div>
<div><button style="position:absolute ; ;top:200px; left:10px;width: 100px; height: 50px;background-color:#202630;" onclick="run(2);">
<font color="green" size="5">ON_2</font></button></div>
<div><button style="position:absolute ; top:200px; left:110px;width: 100px; height: 50px; background-color:#202630;" onclick="stop(2);">
<font color="red" size="5">OFF_2</font></button></div>
<div style="position :absolute ; top:70px; left:250px; width: 100px; height: 50px;background-color:#202630;">
<font color="green" size="10"; id="status1"></font>
</div>
<div style="position :absolute ; top:200px; left:250px; width: 100px; height: 50px;background-color:#202630;">
<font color="green" size="10"; id="status2"></font>
</div>
<script>
var status1;
var status2;
function run(channel)
{
if(channel == 1)
{
digitalWrite(1, 'HIGH');
status1 = "ON";
document.getElementById("status1").innerHTML = status1;
}
if(channel == 2)
{
digitalWrite(2, 'HIGH');
status2 = "ON";
document.getElementById("status2").innerHTML = status2;
}
}
function stop(channel)
{
if(channel == 1)
{
digitalWrite(1, 'LOW');
status1 = "OFF";
document.getElementById("status1").innerHTML = status1;
}
if(channel == 2)
{
digitalWrite(2, 'LOW');
status2 = "OFF";
document.getElementById("status2").innerHTML = status2;
}
}
</script>
</body>
</html>
2: in js
singleButton({name:“Led On”, action:“digitalWrite”,
pin:“2”, value:“HIGH”})
Please help.
Thanks,
Jesal Patel