Arm Community
Arm Community
  • Site
  • User
  • Site
  • Search
  • User
Arm Community blogs
Arm Community blogs
Embedded and Microcontrollers blog Two-way Control with Web and Button
  • Blogs
  • Mentions
  • Sub-Groups
  • Tags
  • Jump...
  • Cancel
More blogs in Arm Community blogs
  • AI blog

  • Announcements

  • Architectures and Processors blog

  • Automotive blog

  • Embedded and Microcontrollers blog

  • Internet of Things (IoT) blog

  • Laptops and Desktops blog

  • Mobile, Graphics, and Gaming blog

  • Operating Systems blog

  • Servers and Cloud Computing blog

  • SoC Design and Simulation blog

  • Tools, Software and IDEs blog

Tags
Actions
  • RSS
  • More
  • Cancel
Related blog posts
Related forum threads

Two-way Control with Web and Button

Dmitry Slepov
Dmitry Slepov
January 19, 2017

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)

 

GitHub Repository

Name: tps-gpio-tutorials

Repository page: https://github.com/tibbotech/tps-gpio-tutorials

Clone URL: https://github.com/tibbotech/tps-gpio-tutorials.git

Updated At: Mon Oct 10 2016

 

Node.js Application

Add the following code to server.js:

server.js

...

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

var wasButtonPressed = false;

button.setDirection('input');

setInterval(function(){
    // 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
        }else{
            ledState = 1;
        }

        //...writes...
        led.setValue(ledState);

        //...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;
    }
},100);

...
 
Anonymous
Embedded and Microcontrollers blog
  • Formally verifying a floating-point division routine with Gappa – part 2

    Simon Tatham
    Simon Tatham
    A method of testing whether a numerical error analysis using Gappa really matches the code it is intended to describe.
    • September 4, 2025
  • Formally verifying a floating-point division routine with Gappa – part 1

    Simon Tatham
    Simon Tatham
    Learn the basics of using Gappa for numerical error analysis, using floating-point division in Arm machine code as a case study.
    • September 4, 2025
  • Building Solutions on Arm: A recap of IEEE Arm Community Technothon project presentation

    Fidel Makatia
    Fidel Makatia
    Read Fidel's account from the Arm Community Technothon!
    • December 4, 2024