8 years, 2 months ago.

How to fix "error 20" identifier p20 is undefined?

  1. include "mbed.h" AnalogIn input(p20); Battery Divider DigitalOut led1(LED1);

int main() { while (1){ if(input > 1.0) { led1 = 1; wait(0.2); led1 = 0; wait(0.2); printf("(%1f)" , input.read()); } } } Here's is my program but still having error.

Hi, first try to use <<code>> <</code>> to render c/c++ code. It is much more readable:

#include "mbed.h" 

AnalogIn input(p20); //Battery Divider;
DigitalOut led1(LED1);

int main() { 
   while (1){ 
      if(input > 1.0) { 
         led1 = 1; 
         wait(0.2); 
         led1 = 0; 
         wait(0.2); 
         printf("(%1f)" , input.read()); 
      } 
   } 
}

Weird, this program compiles fine for me (lpc1768 / lpc11u24).

Sam

posted by Samuel Mokrani 07 Feb 2013

Hi Sam. Thanks for your answer. But I'm still facing the same problem.

posted by NYP ME 07 Feb 2013

Do you have the same problem if you start a new program and copy/paste the code above ? Just to be sure that you are using the latest version of the mbed libraries.

posted by Samuel Mokrani 07 Feb 2013

Yes, I copied and pasted your code above and in my earlier program folder I have been using with same libraries for other AnalogueIn pins but it worked.

posted by NYP ME 07 Feb 2013

Which version of the mbed libraries are you using? Can you post your program ?

posted by Samuel Mokrani 07 Feb 2013

Hi Sam, Thanks for your effort. Since you told me to update the libraries of mbed, i didn't check properly. The library I was using was 2012 library. Now i updated the library and solved. Thank you. :)

posted by NYP ME 07 Feb 2013
Be the first to answer this question.