Hw adc input read

From Sim Innovations Wiki
Jump to navigation Jump to search

Description

value = hw_adc_input_read(hw_adc_input_id)

hw_adc_input_read is used to read the value of a hardware ADC input.

Return value

Argument Type Description
value Number The ADC value. Ranges from 0.0 (GND) to 1.0 (VCC).

Arguments

# Argument Type Description
1 hw_adc_input_id String The is the reference to the ADC input. You can get this reference from the hw_adc_input_add function.

Example

-- Callback function which is called when the ADC input value changes
function adc_input_change(value)
  print("new value = " .. tostring(value) )
end

-- Bind to pin 1 of Hardware port A
id = hw_adc_input_add("HW_PORT_A1", adc_input_change)

-- Read the actual state
value = hw_adc_input_read(id)