Fixed
Status Update
Comments
le...@google.com <le...@google.com> #2
**Copy and pasted my answer from G+ **
We don't really have 'pins'. We have different peripheral buses, such as GPIO, I2C, SPI etc... The notion of having a pin thats either digital or analog is an arduino concept but its an abstraction they use to hide whats going on. Really there are buses/controllers that can be mux'ed to different pins
An analog pin is really an abstraction for an ADC, be it on chip or off chip (via something like SPI). These are much more complicated than the simple arduino model. They have multiple channels, sampling options, reference voltages etc..They can also read at high speed, batching samples and DMA'ing them.
We need to handle the whole variety of ADC/DACs when we build our APIs to support them. We are working on ADC and DAC support to PeripheralManager. This will give you that notion of an analog pin, but really you will be opening an ADC controller, selecting an channel, setting sampling rates etc...then capturing samples at some batch rate. We'll probably also add helper methods so you can do the single spot reads (like an arduino pin).
So look out for this support in upcoming releases.
As Dave says, in the mean time you can connect an ADC via I2C or SPI and use that to read analog signals.
We don't really have 'pins'. We have different peripheral buses, such as GPIO, I2C, SPI etc... The notion of having a pin thats either digital or analog is an arduino concept but its an abstraction they use to hide whats going on. Really there are buses/controllers that can be mux'ed to different pins
An analog pin is really an abstraction for an ADC, be it on chip or off chip (via something like SPI). These are much more complicated than the simple arduino model. They have multiple channels, sampling options, reference voltages etc..They can also read at high speed, batching samples and DMA'ing them.
We need to handle the whole variety of ADC/DACs when we build our APIs to support them. We are working on ADC and DAC support to PeripheralManager. This will give you that notion of an analog pin, but really you will be opening an ADC controller, selecting an channel, setting sampling rates etc...then capturing samples at some batch rate. We'll probably also add helper methods so you can do the single spot reads (like an arduino pin).
So look out for this support in upcoming releases.
As Dave says, in the mean time you can connect an ADC via I2C or SPI and use that to read analog signals.
Description
in com.google.android.things.pio
sample code:
PeripheralManagerService manager = new PeripheralManagerService();
mAnalogPio = manager.openAnalogPio(ANALOG_PIN_NAME);
int value = mAnalogPio.readValue();