Pymate-16ADI16DO-introduction
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.
Board_ID
It is essential to identify the Board_ID of the 16ADI16DO expansion.
Here a reminder of few tutorials around the "Board_ID".
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 10 (on Board_ID 1) and displays the results on the REPL session.
from pymate.pymateio import PymateIO
from machine import Pin
import time
EXT_BOARD = 1
i10 = PymateIO( "IN10", Pin.IN, EXT_BOARD )
while True:
print( "i10= %s" % i10.read() )
time.sleep( 0.5 ) # Wait 1/2 secondWhich would display the following in the REPL:
1 1 1 0 0 1
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
EXT_BOARD = 1
i10 = PymateIO( "IN10", Pin.IN, EXT_BOARD )
while True:
print( "i10= %s" % i10.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 can be used to control relays, 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 (OUT3) every minute while the Pilot Light (OUT12) is lit when the relay is off.
from pymate.pymateio import PymateIO
from machine import Pin
import time
EXT_BOARD = 1
o3 = PymateIO( "OUT3", Pin.OUT, EXT_BOARD )
o12 = PymateIO( "OUT12", Pin.OUT, EXT_BOARD )
state = False
while True:
# Invert the state
state = not(state)
# Set the relay
print( "Relay is %s" % state )
o3.write( state )
# Set the Pilot Light
o12.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
EXT_BOARD = 1
o3 = PymateIO( "OUT3", Pin.OUT, EXT_BOARD )
o12 = PymateIO( "OUT12", Pin.OUT, EXT_BOARD )
state = False
while True:
# Invert the state
state = not(state)
# Set the relay
print( "Relay is %s" % state )
o3.value( state )
# Set the Pilot Light
o12.value( not(state) )
# Wait a minute
time.sleep( 60 )Analog Input
Any of the Input pin can be switched from digital input to Analog Input.
Analog Input can read the value of the DC voltage applied to the analog Input pin.
Wiring
Coding
Getting raw value
The following example query the state if input 7 on Board_ID 1 and displays the results on the REPL session.
from pymate.pymateio import PymateIO
from machine import ADC
import time
EXT_BOARD
a7 = PymateIO( "IN7", ADC, EXT_BOARD )
while True:
print( "Adc 7 RAW = %s" % a4.read_u16() )
time.sleep( 0.2 )Which displays values between 0 and 65535 in the REPL.
Getting voltage
This second example return the ADC value in Volts.
Note the "%.2f" formatting that limits the displayed value to 2 decimal digits (making the reading more comfortable).
from pymate.pymateio import PymateIO
from machine import ADC
import time
EXT_BOARD = 1
a7 = PymateIO( "IN7", ADC, EXT_BOARD )
while True:
v = a7.read_volts()
print( "Adc 7 : %.2f volts" % v )
time.sleep( 0.2 )Board LEDs
The 16ADI16DO expansion board also have two USER LEDs that can be controled remotely as if it were output pins.
from pymate.pymateio import PymateIO
from machine import Pin, ADC
from pymate.pymateio import PymateIO
import time
EXT_BOARD = 1
RemoteLedA = PymateIO( 'LED_1', Pin.OUT, board_id=EXT_BOARD )
RemoteLedB = PymateIO( 'LED_2', Pin.OUT, board_id=EXT_BOARD )
while True:
RemoteLedA.on()
time.sleep_ms(300)
RemoteLedA.off()
RemoteLedB.on()
time.sleep_ms(300)
RemoteLedB.off()
time.sleep_ms(300)As any PymateIO pins, the methods value( 1 ),value( 0 ) or write( 1 ),write( 0 ) or high(),low() could also be used to contrôle the LEDs.
PymateIO all right reserved © 2026 - Written by MCHobby for PymateIO

