This is the documentation for the latest development branch of MicroPython and may refer to features that are not available in released versions.

If you are looking for the documentation for a specific release, use the drop-down menu on the left and select the desired version.

pyb.Switch

Classes

Switch

Create and return a switch object.

Module Contents

class pyb.Switch.Switch

Bases: pyb.Pin.Pin

Create and return a switch object.

__call__() Incomplete

Call switch object directly to get its state: True if pressed down, False otherwise.

callback(fun) None

Register the given function to be called when the switch is pressed down. If fun is None, then it disables the callback.

value() bool

Get the switch state. Returns True if pressed down, otherwise False.