Import
Methods
| Method | Description |
|---|---|
input() | Read digital pin state |
output(level) | Set digital pin state |
wait_for_level(level, ...) | Wait for pin to reach a target level |
Method Reference
Net.get(name, type=NetType.GPIO)
Get a GPIO net by name.
| Parameter | Type | Description |
|---|---|---|
name | str | Name of the GPIO net |
type | NetType | Must be NetType.GPIO |
input()
Read the digital state of the pin.
int - 0 for LOW, 1 for HIGH
output(level)
Set the digital state of the pin.
| Parameter | Type | Description |
|---|---|---|
level | int or str | 0/1, “low”/“high”, “off”/“on”, “true”/“false” |
wait_for_level(level, timeout=None, ...)
Wait for the pin to reach a target level. Blocks until the pin reads the specified level or the timeout expires.
The LabJack T7 uses hardware streaming at up to 20 kHz for fast edge detection. Other hardware uses software polling.
| Parameter | Type | Default | Description |
|---|---|---|---|
level | int or str | required | Target level: 0/1, “low”/“high”, “off”/“on” |
timeout | float or None | None | Maximum seconds to wait. None = wait forever. |
scan_rate | int | 20000 | Sample rate in Hz (LabJack T7 only) |
scans_per_read | int | 2 | Batch size per read (LabJack T7 only; lower = faster reaction) |
poll_interval | float | 0.01 | Seconds between polls (non-LabJack hardware only) |
float - Elapsed time in seconds until the level was detected
Raises: TimeoutError if the timeout expires before the target level is reached
Hardware-specific behavior:
| Hardware | Method | Default Rate |
|---|---|---|
| LabJack T7 | Hardware streaming (ljm.eStreamStart) | 20,000 Hz |
| USB-202 | Software polling | 100 Hz (10 ms interval) |
Examples
Read Button State
Control LED
Wait for Interrupt
Button-Controlled LED
Toggle Output
Supported Hardware
| Hardware | Pins | Logic Level |
|---|---|---|
| LabJack T7 | FIO0-FIO7, EIO0-EIO7, CIO0-CIO3 | 3.3V |
| MCC USB-202 | DIO0-DIO7 | 5V TTL |
Pin Naming
LabJack T7:| Pin Input | Channel |
|---|---|
0-7 | FIO0-FIO7 |
8-15 | EIO0-EIO7 |
16-19 | CIO0-CIO3 |
"FIO0"-"FIO7" | FIO0-FIO7 |
| Pin Input | Channel |
|---|---|
0-7 | DIO0-DIO7 |
"DIO0"-"DIO7" | DIO0-DIO7 |
Notes
- GPIO nets work directly without
enable()/disable()calls input()returns 0 or 1output()accepts integers (0/1) or strings (“high”/“low”, “on”/“off”, “true”/“false”)wait_for_level()blocks the calling thread until the target level is detected- LabJack T7
wait_for_level()uses hardware streaming for sub-millisecond detection - Net names must match those configured on the Lager Box

