baz
June 18, 2013, 6:43am
1
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
Brett
June 18, 2013, 6:53am
2
add your reference to GHI.OSHW.Hardware
Then you can use GHI.OSHW.Hardware.FEZCerbuino.Pin.AnalogIn enums
baz
June 18, 2013, 6:57am
3
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 …
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?
baz
June 18, 2013, 7:09am
4
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
baz
June 18, 2013, 7:15am
5
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
baz
June 18, 2013, 9:57am
7
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?
baz
June 18, 2013, 10:44am
9
Name “A0” -> Pin “PB1” -> GHI.Hardware.FEZCerb.Pin.PB1
Ok, got it
thanks
baz
June 18, 2013, 10:58am
10
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
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))