您的位置:首页 > 其它

5、继电器+LED(简单的io口)

2015-08-18 09:26 330 查看
继电器用法比较简单,和LED类似

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

/**
* main() function
* @return 0. int return type required by ANSI/ISO standard.
*/
int main(void)
{
uint8_t output_state = 0;
uint8_t i;

// Configure LED-pins as outputs
nrf_gpio_range_cfg_output(LED_START, LED_STOP);
nrf_gpio_cfg_output(LED_GREEN);
nrf_gpio_cfg_output(LED_BLUE);
nrf_gpio_cfg_output(LED_RED);
nrf_gpio_cfg_output(RELAY);
nrf_gpio_pin_set(LED_GREEN);
nrf_gpio_pin_set(LED_BLUE);
nrf_gpio_pin_set(RELAY);

while(true)
{
for(i = 0; i < 7; i++)
{
nrf_gpio_pin_set(LED_RED);
nrf_gpio_pin_set(LED_BLUE);
nrf_gpio_pin_toggle(LED_GREEN);
nrf_gpio_pin_toggle(RELAY);
nrf_delay_ms(100);
nrf_delay_ms(100);
nrf_delay_ms(100);
}
for(i = 0; i < 7; i++)
{
nrf_gpio_pin_set(LED_RED);
nrf_gpio_pin_set(LED_GREEN);
nrf_gpio_pin_toggle(LED_BLUE);
nrf_gpio_pin_toggle(RELAY);
nrf_delay_ms(100);
nrf_delay_ms(100);
nrf_delay_ms(100);
}

for(i = 0; i < 7; i++)
{
nrf_gpio_pin_set(LED_GREEN);
nrf_gpio_pin_set(LED_BLUE);
nrf_gpio_pin_toggle(LED_RED);
nrf_gpio_pin_toggle(RELAY);
nrf_delay_ms(100);
nrf_delay_ms(100);
nrf_delay_ms(100);
}

}
}


链接:http://pan.baidu.com/s/1i3rQrjR
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: