[PIGET] Buttons

[PIGET] Buttons

We will learn how to launch commands with buttons.

In this tutorial, we are going to :

  • Plug two buttons
  • Setup buttons to turn off or reboot our Raspberry Pi
  • Use other commands with the buttons module
  • Setup buttons from Windows
Prerequisite: Piget

Needed components

Composants Prix Liens
Buttons 2.43$ — 1.20$
Breadboard 2.8$ – 1.21$
Dupont cables 1.96$ – 1.25$
Total : 7.19$ – 3.66$

Plug a button

We will see how to plug two buttons on our Raspberry Pi:

Button 1

Bouton 2



  • Take the first pin of each button and wire it to the Raspberry Pi


gpio Boutons

  • Take the next pin and wire it together
  • Then wire it to the ground (GND) of the Raspberry Pi

Schéma bouton

Why the button is not wired to VCC?

Setup buttons

  • To install button module, Type in your terminal:

/pi/install buttons

This will install buttons service which will watch all buttons setup in /user/config/buttons/buttons.cfg

  • To setup buttons type:


nano buttons.cfg
All shortcuts are written on the bottom of the screen. For example,  to save (write) ^O or CTRL-O, to exit : CTRL-X

Each buttons are setup in a block of text which starts with a [B Pin], for example [B19] or [B26].
There are twos parameters :

  • action = command to launch
  • timer = times before the action is restarted
What is the line timer = ?

For example, if we want a button to :

  • Turn off our Raspberry Pi (poweroff)
  • Reboot our Raspberry Pi (reboot)
To exit nano press:

  • CTRL-O then ENTER
  • CTRL-X then ENTER

This will automatically restart button service and display the log in order to try the buttons.


Here are all the commands of button module :

  • Setup the button service: /do/buttons/settings
  • Setup 19/26 buttons pour shutdown and restart: /do/buttons/poweroffReboot
  • Simulate a button press on pin 26: /do/buttons/press 26
  • Display button state on pin 26: /do/buttons/state 26
  • Display settings: /do/buttons/commands
  • Display logs: /do/buttons/log
  • Display logs live: /do/buttons/tailLog
  • Restart le bouton service: /do/buttons/restart
  • Start button service: /do/buttons/start
  • Stop button service: /do/buttons/stop
  • Uninstall le service bouton: /do/buttons/remove
  • Start button service in debug mode: /do/buttons/check
How button service works ?

Setup without terminal

If you want to be able to setup buttons without the terminal.

  • Then using Windows explorer go to your Raspberry Pi (for example : \\madnerd)
  • Go to \user\config\buttons (for example : \\MADNERD\user\config\buttons )
  • Open file buttons.cfg with your favourite text editor
  • The first button will blink a led on pin 21
  • The second button will restart button service
We can now, modify what button 1 do without using the terminal.
Press button 2 to update the settings.


Comments are closed.