当前位置:网站首页>nRF52832 GPIO LED

nRF52832 GPIO LED

2022-06-30 07:11:00 Delta-delta

Hardware connection

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-97lMAaG5-1628948677824)(image/image-20210812192306259.png)]

initialization GPIO

nrf_gpio_cfg_output( Pin number );

Buy low

nrf_gpio_pin_clear( Pin number );

Set high

nrf_gpio_pin_set( Pin number );

Flip

nrf_gpio_pin_toggle( Pin number );

Example

#include <stdbool.h>
#include <stdint.h>
#include "nrf_delay.h"


#define LED_B 24
#define LED_R 23
#define LED_G 22

/** * @brief Function for application main entry. */
int main(void)
{
    
    /* Configure board.  initialization GPIO For export */
    nrf_gpio_cfg_output(LED_G);
	nrf_gpio_cfg_output(LED_R);
	nrf_gpio_cfg_output(LED_B);
		
		// Turn on the light when set low 
	nrf_gpio_pin_clear(LED_B);
	nrf_gpio_pin_clear(LED_G);
	nrf_gpio_pin_clear(LED_R);
    /* Toggle LEDs. */
    while (true)
    {
    
       
            nrf_gpio_pin_toggle(LED_R);
			nrf_gpio_pin_toggle(LED_G);
			nrf_gpio_pin_toggle(LED_B);
            nrf_delay_ms(500);
        
    }
}
原网站

版权声明
本文为[Delta-delta]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202160545083924.html