pinpong pin class

Pin Class


Creates and initializes a pin.

pin = Pin(board, vpin, mode)

For example, to define a digital input such as a button,

button_pin = Pin(Pin.D8, Pin.IN)

To define an analog sensor pin,

Analog_pin = Pin(Pin.A0)


When called with no arguments, it performs a digital read, returning 0 or 1.
v = button_pin.value()  # Get the state of pin button_pin
When called with an argument, it performs a digital write.
pin.value(1)  # Set pin to high level
Sets the pin to high level, equivalent to pin.value(1).
Sets the pin to low level, equivalent to pin.value(0).
pin.irq(trigger, handler)
Sets an interrupt.
- trigger: Interrupt mode, rising - rising edge, falling - falling edge, low - low level, high - high level...
- handler: The function to be called when the interrupt is triggered.