Pymate-Input-Output
Important note
Charts and graphics are made to be easy to follow.
The Pymate boards are drawed without connectors to avoids parallax shift. The real board are fitted with the connectors.
Input
Input are high when voltage on the Input is higher than 8V.
Input return to low state when the voltage drops under 5V
Wiring
Coding
The following example query the state if imput 3 and displays the results on the REPL session.
from pymate.pymateio import PymateIO
from machine import Pin
import time
i3 = PymateIO( "IN3", Pin.IN )
while True:
print( "i3= %s" % i3.read() )
time.sleep( 0.5 ) # Wait 1/2 secondWhich would display the following in the REPL:
1 1 0 1 0 0
Where:
- 0 is at LOW state, meaning that low voltage is applied on the input (< 5 Volts).
- 1 is at HIGH state, meaning that high voltage is applied on the input (> 8 Volts).
MicroPython alike call
MicroPython coder usually use Pin.value() to read the state of an input.
Such method is also available on the PymateIO class to act like an usual `Pin` class.
The script above could also be written by using value() instead of read() as follow:
from pymate.pymateio import PymateIO
from machine import Pin
import time
i3 = PymateIO( "IN3", Pin.IN )
while True:
print( "i3= %s" % i3.value() )
time.sleep( 0.5 ) # Wait 1/2 secondOutput
Output will connect the high side of the load to Vin (250 mA per channel) with a PNP transistor.
It is quite convenient to control relais, pilot light, etc.
Wiring
The following example controls a 24V relay connected to output 2 and a 24V Pilot Light to output 8.
Coding
The following example change the state of the relay (OUT2) every minute while the Pilot Light (OUT8) is lit when the relay is off.
from pymate.pymateio import PymateIO
from machine import Pin
import time
o2 = PymateIO( "OUT2", Pin.OUT )
o8 = PymateIO( "OUT8", Pin.OUT )
state = False
while True:
# Invert the state
state = not(state)
# Set the relay
print( "Relay is %s" % state )
o2.write( state )
# Set the Pilot Light
o8.write( not(state) )
# Wait a minute
time.sleep( 60 )Which would display the following in the REPL:
Relay is True Relay is False Relay is True Relay is False ...
MicroPython alike call
MicroPython coder usually use `Pin.value( new_value )` to write the state of an output.
Such method is also available on the PymateIO class to act like an usual `Pin` class.
The script above could also be written by using:
- value(new_state) instead of write()
- on() & off() instead of write()
- high() & low() as replacement of on() and off().
from pymate.pymateio import PymateIO
from machine import Pin
import time
o2 = PymateIO( "OUT2", Pin.OUT )
o8 = PymateIO( "OUT8", Pin.OUT )
state = False
while True:
# Invert the state
state = not(state)
# Set the relay
print( "Relay is %s" % state )
o2.value( state )
# Set the Pilot Light
o8.value( not(state) )
# Wait a minute
time.sleep( 60 )PymateIO all right reserved © 2026 - Written by MCHobby for PymateIO