9 years, 11 months ago.

question about AnalongIn

I programed following code:

AnalogIn ain(p16);

DigitalOut led(LED1);

int main() {

while (1){

if(ain > 0.3) {

led = 1;

} else {

led = 0;

}

}

}

But this phenomen is that LED0 and LED1 is Interactive flash.But if I changed into this: DigitalIn ain(p16); It's OK.

What's the reason?Thank you!

Question relating to:

The nRF51822-mKIT is a low cost ARM mbed enabled development board for Bluetooth® Smart designs with the nRF51822 SoC. The kit gives access to all GPIO pins via pin headers …

I'd like to know where in the /documentation/ does it state the pin names you can use in the source code?

I've found this: http://mbed.org/users/mbed_official/code/mbed-src/file/cb4253f91ada/targets/hal/TARGET_NORDIC/TARGET_NRF51822/analogin_api.c

So I've used 'p1' and 'p2' which seem to map to P0_1 and P0_2 respectively, although there seems to be some kind of crossover in the readings and it only works with one analog sensor attached, another post I think.

posted by Wayne Keenan 22 May 2014

1 Answer

9 years, 11 months ago.

See: http://mbed.org/platforms/Nordic-nRF51822/. p16 is not an AnalogIn pin. What you see is an error pattern, because it cannot make an AnalogIn object on that pin.

Accepted Answer

Thank you very much.

posted by youyou yu 15 Apr 2014