Hw input read

From Sim Innovations Wiki
Revision as of 11:07, 12 November 2017 by Admin (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Description

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.

Arguments

# 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.

Example

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

-- 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)