obj
AnalogIn.swift:51This declaration is gated by at least one @_spi attribute.
let obj: UnsafeMutableRawPointer
This declaration is gated by at least one @_spi attribute.
let obj: UnsafeMutableRawPointer
import SwiftIO
The SwiftIO library allows you to access and control the hardware in an easy way.
final class AnalogIn
The AnalogIn class reads external voltage from an analog input pin, which functions like a multimeter for measuring input values.
@frozen struct UnsafeMutableRawPointer
A raw pointer for accessing and manipulating untyped data.
init(_ idName: Id)
Initializes a specified pin as AnalogIn.
var maxRawValue: Int { get }
The max raw value of the ADC. It depends on ADC resolution, i.e. 255 for an 8-bit ADC and 4095 for a 12-bit ADC.
var refVoltage: Float { get }
The reference voltage of the ADC.
var resolutionBits: Int { get }
The number of bits in the absolute value of the ADC. Different ADC has different resolutions. The max raw value of an 8-bit ADC is 255 and that one of a 10-bit ADC is 4095.
func read() -> Int
Reads the raw value representing the analog voltage level on the specified pin. It’s the same as readRawValue()
.
func readPercentage() -> Float
Read the percentage of current input in relation to the max value from a specified analog pin.
func readRawValue() -> Int
Reads the raw value representing the analog voltage level on the specified pin.
func readVoltage() -> Float
Reads the input voltage from a specified analog pin.