hw_input()

Returns the state of the input port or an individual pin on that port.

First pin has index 1.

When the index is omitted or set to -1, returns the entire input value.

Syntax

planetcnc.hw_input()
planetcnc.hw_input(index)

Parameters

Parameter Type Description Comment
index int Optional pin index. First pin is 1. Omit to return full input. optional

Return Value

Examples

#! /usr/bin/env python
 
import planetcnc
 
# Get the complete input port state
full_input = planetcnc.hw_input()
print("Full Input:", full_input)
 
# Get the state of the first pin
pin1_state = planetcnc.hw_input(1)
print("Pin 1 state:", pin1_state)

See also