Help answer threads with 0 replies.
Go Back > Blogs > Dmitry_Slepov
User Name


Rate this Entry

Two-way Control with Web and Button

Posted 01-20-2017 at 07:22 AM by Dmitry_Slepov
Updated 01-30-2017 at 12:12 PM by Dmitry_Slepov
Tags arm, linux, nodejs, tibbo

About the Application
You can expand the functionality of the prev app if you add a hardware button control. Pressing the button will also toggle the state of the GPIO line (LED, relay,...) which is reflected in the LED state displayed in the browser window.

What you need
Besides the hardware used in the prev app you will also need:
  • 1 x Tibbit #38 (push button)
  • 1 x Tibbit #00_3 (2 direct I/O Lines with 5V and Ground)

Proposed Tibbit configuration

GitHub Repository
Name: tps-gpio-tutorials
Repository page:
Clone URL:
Updated At: Mon Oct 10 2016

Node.js Application
Add the following code to server.js:

var button = gpio.init("S11A");

var wasButtonPressed = false;


    // If button is just released...
    if(button.getValue() === 1 && wasButtonPressed === true){
        wasButtonPressed = false;

        // ...reads the LED state...
        var ledState = led.getValue();

        //...inverses it...
        if(ledState === 1){
            ledState = 0
            ledState = 1;


        //...and submits to the web app if connected
        if(clients !== undefined){
            clients.emit('tps:state:changed', ledState);
    }else if(button.getValue() === 0){
        // If button is pressed
        wasButtonPressed = true;

To learn more click here
Posted in Uncategorized
Views 900 Comments 0
« Prev     Main     Next »
Total Comments 0




All times are GMT -5. The time now is 07:56 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration