How to connect two leds at same time and make it glow

i need ur help guys i need to use two leds for my project can u help me guys

Hi,
Use this code to connect two leds. Use same ground pin for both the leds. You may use pin 1,2,3 or 4 instead of A0 pin.

   <script type="text/javascript" src="https://cloud.boltiot.com/static/js/boltCommands.js"></script>
    <script>
    setKey('{{ApiKey}}','{{Name}}');
    </script>
</head>
<body>
    <center>
    <button onclick="digitalWrite(0, 'HIGH');">ON</button>
    <button onclick="digitalWrite(0, 'LOW');">OFF</button>
    <button onclick="digitalWrite(A0,'HIGH');>ON</button>
    <button onclick="digitalWrite(A0, 'LOW');">OFF</button>

i hope this will give you your desired result.
Let me know if this work.

Hi @push1970

You can use digitalMultiwrite command to control multiple pins using a single call.

https://cloud.boltiot.com/remote/{API_KEY}/digitalMultiWrite?pins=4,1,2&states=HIGH,LOW,HIGH&deviceName={DEVICE_ID}

1 Like

Thanks you sir I got it :+1:

I tried this command but it’s not working
Could you please send me the complete html code(for bolt cloud) to control three pin of bolt IoT module(like controlling three LEDs).

@vraj0612

Please check the command again and make sure you replace api_key and device_name correctly.

Hi @yeshwant.naik

Bolt IoT Platform ON OFF
<script type="text/javascript" >
function ledon()
{
    digitalWrite(1,'HIGH')&digitalWrite(2,'HIGH')&digitalWrite(3,'HIGH');
}
function ledoff()
{
   digitalWrite(1,'LOW')&digitalWrite(2,'LOW')&digitalWrite(3,'LOW');
}
    
</script>

//The above code is running quite well but when i’m using the command
digitalMultiWrite?pins=1,2,3&states=HIGH,LOW,HIGH;
in place of digitalWrite(1,‘HIGH’)&digitalWrite(2,‘HIGH’)&digitalWrite(3,‘HIGH’);
Then LEDs are not glowing(not even a single LED).
Could you please guide me in writing the digitalMultiWrite cmd in above code to perform the same activity.

@push1970 I will suggest you to use the bread-board if you want to use two led at the same time with same pin. Just make sure that you will need a bread-board and jumping wires. otherwise you can go with the different coding