pinpong pin class

Pin Class

Constructor

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)

Methods

pin.value()
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
pin.value(x)
When called with an argument, it performs a digital write.
pin.value(1)  # Set pin to high level
pin.on()
Sets the pin to high level, equivalent to pin.value(1).
pin.off()
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.