How to use GPIO pins as input and output on bolt

Hi @mailtoaswinth,

Let me correct you there, the Bolt has 1 analog input, and 5 GPIOs.

To use a GPIO as an input simply configure it for monitoring in the hardware section of the product configuration.

To use any GPIO as an output, you can use the following code in the product code configurations.

    <!DOCTYPE html>

<html>

    <head>

        <title>Bolt IoT Platform</title>

        <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>

        </center>

    </body>

</html>

You can have as many buttons in the code as you want.
The above code allows you control over pin 0, to control the other pin, just change the number ‘0’ inside the digitalWrite function to the pin number that you want to control.

1 Like