- makeITcircular 2024 content launched – Part of Maker Faire Rome 2024Posted 2 months ago
- Application For Maker Faire Rome 2024: Deadline June 20thPosted 3 months ago
- Building a 3D Digital Clock with ArduinoPosted 8 months ago
- Creating a controller for Minecraft with realistic body movements using ArduinoPosted 9 months ago
- Snowflake with ArduinoPosted 9 months ago
- Holographic Christmas TreePosted 10 months ago
- Segstick: Build Your Own Self-Balancing Vehicle in Just 2 Days with ArduinoPosted 10 months ago
- ZSWatch: An Open-Source Smartwatch Project Based on the Zephyr Operating SystemPosted 11 months ago
- What is IoT and which devices to usePosted 11 months ago
- Maker Faire Rome Unveils Thrilling “Padel Smash Future” Pavilion for Sports EnthusiastsPosted 12 months ago
Two-way Control with Web and Button
Web site:
http://tibbo.com/linux/nodejs/two-way-control-web-button.htmlProject Summary:
This is the simplest application enabling the control of a GPIO line through a hardware button.
Full Project:
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); ...