<!doctype html>
Bolt IoT Platform ON OFF ON OFF i have used pin no 2 you can use any pin as per our conviniceYes you can use 2 pins
Yes, you can actually use two pins, you just have to change the value of the second pin.
For eg- you can connect the 1st pin in A0 , and second pin in 0 , using a bread board for connections will be preferred.
USE THIS CODE TO CONTROLL 2 LEDS
use the digital pin 0 to connect the first LED and use the digital pin 1 to connect the second LED to the BOLT WIFI MODULE
Bolt IoT Platform TURNON 1 TURNOFF 1 TURNON 2 TURNOFF 2Hi , To control two led’s you can use any pins available on bolt iot wifi modulu i.e., GPIO - (0,1,2,3,4) as per your convenience. Make sure all connections are properly made and also you can use breadboard to make connections properly. Also check whether the pin numbers of led correctly written in code respectively.
Hi, @ramesh00845
You can certainly do that, there is nothing to worry about it. Here’s an example of HTML and JavaScript code to control two LEDs using the Bolt IoT Platform:
Control Two LEDsControl Two LEDs
<button id="led1-on">LED 1 ON</button>
<button id="led1-off">LED 1 OFF</button>
<br><br>
<button id="led2-on">LED 2 ON</button>
<button id="led2-off">LED 2 OFF</button>
<script>
$(document).ready(function() {
$("#led1-on").click(function() {
controlLED(1, 'on');
});
$("#led1-off").click(function() {
controlLED(1, 'off');
});
$("#led2-on").click(function() {
controlLED(2, 'on');
});
$("#led2-off").click(function() {
controlLED(2, 'off');
});
});
function controlLED(pinNumber, state) {
var baseUrl = "https://cloud.boltiot.com/remote/";
var apiKey = "YOUR_API_KEY"; // Replace with your Bolt IoT API key
var deviceName = "YOUR_DEVICE_NAME"; // Replace with your Bolt IoT device name
var url = baseUrl + apiKey + "/digitalWrite?pin=" + pinNumber + "&state=" + state + "&deviceName=" + deviceName;
$.get(url, function(data, status) {
console.log(data);
console.log(status);
});
}
</script>
Replace "YOUR_API_KEY"
with your actual Bolt IoT API key and "YOUR_DEVICE_NAME"
with the name of your Bolt IoT device.
It uses the digitalWrite
function from the Bolt IoT platform to control the state of the LEDs connected to the specified pins.
The HTML page will display four buttons: “LED 1 ON”, “LED 1 OFF”, “LED 2 ON”, and “LED 2 OFF”. Clicking these buttons will send requests to the Bolt IoT platform to control the respective LEDs connected to the specified pins.
Remember to host this HTML page on a web server or use a local development environment to run the code and interact with the Bolt IoT platform. Make sure to connect the LEDs to the appropriate GPIO pins on your Bolt IoT device.