This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

GPIO configuration code

Sir,

We want to know about sample code of how to configure GPIO pins as output, and let we know how to include them for led toggling.

Parents
  • To configure a pin as output you just need to use (Assuming your LED is on pin 29)

    #define LED_PIN 29
    
    nrf_gpio_cfg_output(LED_PIN);// Set LED PIN pin as output
    
    To set the pin to High , use
    
    nrf_gpio_pin_set(LED_PIN);
    
    to set the pin to low, use
    
    nrf_gpio_pin_clear(LED_PIN);
    
    to toggle the pin use
    
    nrf_gpio_pin_toggle(LED_PIN);
    

    Note. You need to include "nrf_gpio.h"

Reply
  • To configure a pin as output you just need to use (Assuming your LED is on pin 29)

    #define LED_PIN 29
    
    nrf_gpio_cfg_output(LED_PIN);// Set LED PIN pin as output
    
    To set the pin to High , use
    
    nrf_gpio_pin_set(LED_PIN);
    
    to set the pin to low, use
    
    nrf_gpio_pin_clear(LED_PIN);
    
    to toggle the pin use
    
    nrf_gpio_pin_toggle(LED_PIN);
    

    Note. You need to include "nrf_gpio.h"

Children
Related