analogIn on Cerbuino

Hello,
I’ve trouble trying to read data from analog input (arduino layout pins) on my Cerbuino Bee.

I try:

        _adc = New Microsoft.SPOT.Hardware.AnalogInput(DirectCast(GHI.Hardware.FEZCerb.Pin.PA0, Microsoft.SPOT.Hardware.Cpu.AnalogChannel), 10)

return _adc.Read

but it’s wrong.
I know that there is some enum with channels of the Bee, but I cannot find it.

Anyone can help me?
thanks

add your reference to GHI.OSHW.Hardware

Then you can use GHI.OSHW.Hardware.FEZCerbuino.Pin.AnalogIn enums

I’ve tried that before to write, but there is something wrong.

I’ve the reference to GHI.OSHW.Hardware, versione 4.2.5.0, but I cannot find the namespace
GHI.OSHW.Hardware.FEZCerbuino … :frowning:

GHI.OSHW.Hardware reports other classes but not any FEZCerbuino. In fact if I try to find it with object browser, the most similar reported is just GHIElectronics.Gadgeteer.FEZCerbuinoBee

Where is my error?

I’ve also tried

  
_adc = New Microsoft.SPOT.Hardware.AnalogInput(CType(10, Microsoft.SPOT.Hardware.Cpu.AnalogChannel), 10)

using the channel documented here: https://www.ghielectronics.com/docs/45/fez-cerbuino-bee-developer#395

but I’ve a runtime
An unhandled exception of type ‘System.ArgumentException’ occurred in Microsoft.SPOT.Hardware.dll

Maybe I’ve solved passing


Hardware.Cpu.Pin.GPIO_Pin10

as parameter to AnalogIn constructor, and REMOVING the second parameter (10, precisionInBits)

@ baz - GHI.Hardware.FEZCerb has Pin enums

Thank you, I tried that enum, but maybe it reported the runtime error caused by the second parameter I was passing to the constructor and I didn’t understand that.

Just a question: if I need to read the first pin (A0), I may pass


GHI.Hardware.FEZCerb.Pin.PA0

not


GHI.Hardware.FEZCerb.Pin.PA10

Is this right?

from http://www.ghielectronics.com/docs/45/fez-cerbuino-bee-developer#395 A0 is GHI.Hardware.FEZCerb.Pin.PB1

Name “A0” -> Pin “PB1” -> GHI.Hardware.FEZCerb.Pin.PB1

Ok, got it

thanks

Runtime: “An unhandled exception of type ‘System.ArgumentException’ occurred in Microsoft.SPOT.Hardware.dll”

executing


   _adc = New Microsoft.SPOT.Hardware.AnalogInput(CType(pin, Microsoft.SPOT.Hardware.Cpu.AnalogChannel))

with pin= GHI.Hardware.FEZCerb.Pin.PB1

:frowning:

my mistake you need a channel not a pin. going back to https://www.ghielectronics.com/docs/45/fez-cerbuino-bee-developer#395

I think your code should be:

adc = New Microsoft.SPOT.Hardware.AnalogInput(CType(10, Microsoft.SPOT.Hardware.Cpu.AnalogChannel))

This works, thanks