Button

../../_images/pk_button.jpg
Button

Description

A standard momentary push button.

Buttons are used in a wide variety of applications to take user input.

Usage

It is digital which means it reads either HIGH or LOW.

This device reads HIGH by default and LOW when pressed.

Voltage Range

0 - 5V

Interface Type

Digital Input

Example Usage

from microbit import *

while True:
  btn_val = pin0.read_digital()

  if btn_val == 0:
    # button is pressed
    # ...do something
  else:
    # button is NOT pressed
    # ...do something