-
Notifications
You must be signed in to change notification settings - Fork 2
/
demo_leds.c
79 lines (62 loc) · 1.87 KB
/
demo_leds.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//#include <stdio.h>
//#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include "delay.h"
#include "nrf_gpio.h"
/*
* Color LEDs
*/
#define PIN_LED_RED_BRIGHT 1
#define PIN_LED_GREEN 2
#define PIN_LED_YELLOW_1 3
#define PIN_LED_WHITE_1 4
#define PIN_LED_YELLOW_2 5
#define PIN_LED_BLUE 6
#define PIN_LED_RED 7
#define PIN_LED_WHITE_2 8
void setup_led_pins()
{
nrf_gpio_pin_dir_set(PIN_LED_RED_BRIGHT, NRF_GPIO_PIN_DIR_OUTPUT);
nrf_gpio_pin_dir_set(PIN_LED_GREEN, NRF_GPIO_PIN_DIR_OUTPUT);
nrf_gpio_pin_dir_set(PIN_LED_YELLOW_1, NRF_GPIO_PIN_DIR_OUTPUT);
nrf_gpio_pin_dir_set(PIN_LED_WHITE_1, NRF_GPIO_PIN_DIR_OUTPUT);
nrf_gpio_pin_dir_set(PIN_LED_YELLOW_2, NRF_GPIO_PIN_DIR_OUTPUT);
nrf_gpio_pin_dir_set(PIN_LED_BLUE, NRF_GPIO_PIN_DIR_OUTPUT);
nrf_gpio_pin_dir_set(PIN_LED_RED, NRF_GPIO_PIN_DIR_OUTPUT);
nrf_gpio_pin_dir_set(PIN_LED_WHITE_2, NRF_GPIO_PIN_DIR_OUTPUT);
}
#define on(led) nrf_gpio_pin_set(led)
#define off(led) nrf_gpio_pin_clear(led)
int main()
{
setup_led_pins();
while(true)
{
off(PIN_LED_WHITE_2);
on(PIN_LED_RED_BRIGHT);
delay_ms(1000);
off(PIN_LED_RED_BRIGHT);
on(PIN_LED_GREEN);
delay_ms(1000);
off(PIN_LED_GREEN);
on(PIN_LED_YELLOW_1);
delay_ms(1000);
off(PIN_LED_YELLOW_1);
on(PIN_LED_WHITE_1);
delay_ms(1000);
off(PIN_LED_WHITE_1);
on(PIN_LED_YELLOW_2);
delay_ms(1000);
off(PIN_LED_YELLOW_2);
on(PIN_LED_BLUE);
delay_ms(1000);
off(PIN_LED_BLUE);
on(PIN_LED_RED);
delay_ms(1000);
off(PIN_LED_RED);
on(PIN_LED_WHITE_2);
delay_ms(1000);
}
return 0;
}