Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
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:
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.
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