I am using nrf51822 DK. How to set GPIO pins as output pins and access the pins to set or reset the output.For example if I want to use pin 20 as output, how to configure that.I need the code syntax to do that. Can you please point out to any examples or code snippets if any?
Can you also please tell me how to configure LEDs output on the board. There are four LEDs on the board. For example if I want to toggle 4th LED how to do that?
You are probably looking for LED blinky example in SDK v12.3.0 (the newest which supports nRF51 chips).
(As this is pretty basic example mentioned in every beginners' tutorial one would wonder how long have you tried to solve your question yourself before posting to the forum;)
As endnode said in his answer, the blinky example is a good place to start.
In my opinion the easiest way to control the LED is to use the nrf_gpio interface directly.
Configuring a pin as output: nrf_gpio_cfg_pin_output(pin_number);
Turn on/off the led: nrf_gpio_pin_set(pin_number); / nrf_gpio_pin_clear(pin_number);
Which pin that is connected to the different LEDs, you can find in the product specification, or on the backside of your nRF51 DK.
Thank you Joakim.