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.
10 years, 5 months ago.
how do I know that which pin is for LED1 or LED2 ?
this is my first day with ARM. is LED1 a keyword in a specific library? and how will I know that which pin is defined for this? can't I directly use pin no. as p1 or p2?
Question relating to:
1 Answer
10 years, 5 months ago.
Yes you can use a specific pin.
However there are lots of different mbed boards, if you used a specific pin then you would need to change the pin to match the type of mbed board you are using. Since just about all mbeds have at least 1 LED built onto them the libraries (normally) define LED1 as being the pin name for the first LED on the board. That way the same code will work on any mbed board without any modification.
Many boards will also define an LED2, LED3 etc... depending on how many LEDs they have. (The LPC1768 module has 4).
If you want to use an IO pin rather than the on board LED change LED1 to a pin number like p10 (which is then defined by the libraries to be the CPU pin connected to IO 10 on that specific board) or you can directly specify the CPU IO pin to use e.g. P0_1 (GPIO port 0, pin 1)
To answer the other part of your question - how do you find the value of LED1... Since this is hardware specific you need to look either in the source code for the mbed libraries or at the PCB schematic.
Assuming you want to look it up in the libraries in the compiler right click on the mbed library and select convert to folder. This will take a while. Once it is done you can view all of the header files used in the mbed library. Work your way down the folder tree for the CPU/mbed board you are using and find the PinNames.h file for your board. e.g. for the LPC1768 mbed board it's TARGET_LPC1768/TARGET_NXP/TARGET_LPC176X/TARGET_MBED_LPC1768/PinNames.h
In that file you can then look up all of the CPU GPIO pin aliases that have been defined for that boad. e.g.
LED1 = P1_18, LED2 = P1_20, LED3 = P1_21, LED4 = P1_23,
posted by 09 Jun 2015