analogIn on Cerbuino

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?

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, 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:

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

Maybe I’ve solved passing


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




Is this right?

from A0 is GHI.Hardware.FEZCerb.Pin.PB1

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

Ok, got it


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


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

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


my mistake you need a channel not a pin. going back to

I think your code should be:

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

This works, thanks