Hw input read

From Sim Innovations Wiki
Jump to navigation Jump to search


state = hw_input_read(hw_input_id)

hw_input_read is used to read the state of a hardware input.

Return value

Argument Type Description
state Boolean The pin state. True is pin high, false is pin low.


# Argument Type Description
1 hw_input_id String The is the reference to the input. You can get this reference from the hw_input_add function.


-- Callback function which is called when the input state changes
function input_change(state)
  print("new state = " .. tostring(state) )

-- Bind to Raspberry Pi 2, Header P1, Pin 40
inp_id = hw_input_add("RPI_V2_P1_40", input_change)

-- Read the actual state
-- state true  : input is high
-- state false : input is low
state = hw_input_read(inp_id)