add rgb blink
This commit is contained in:
parent
6d19e1dc97
commit
89f2db72d0
@ -9,12 +9,12 @@ project(my_project)
|
|||||||
# initialize the Raspberry Pi Pico SDK
|
# initialize the Raspberry Pi Pico SDK
|
||||||
pico_sdk_init()
|
pico_sdk_init()
|
||||||
|
|
||||||
add_executable(hello_world
|
add_executable(my_project
|
||||||
src/main.c
|
src/main.c
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add pico_stdlib library which aggregates commonly used features
|
# Add pico_stdlib library which aggregates commonly used features
|
||||||
target_link_libraries(hello_world pico_stdlib)
|
target_link_libraries(my_project pico_stdlib)
|
||||||
|
|
||||||
# create map/bin/hex/uf2 file in addition to ELF.
|
# create map/bin/hex/uf2 file in addition to ELF.
|
||||||
pico_add_extra_outputs(hello_world)
|
pico_add_extra_outputs(my_project)
|
||||||
|
|||||||
33
src/main.c
33
src/main.c
@ -1,9 +1,36 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "pico/stdlib.h"
|
#include "pico/stdlib.h"
|
||||||
|
|
||||||
|
// pin rgb led on Seeed XIAO RP2040
|
||||||
|
#define PIN_RGB_R 17
|
||||||
|
#define PIN_RGB_G 16
|
||||||
|
#define PIN_RGB_B 25
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
setup_default_uart();
|
setup_default_uart();
|
||||||
printf("Hello, world!\n");
|
printf("Hello, world!\n");
|
||||||
return 0;
|
|
||||||
|
gpio_init(PIN_RGB_R);
|
||||||
|
gpio_set_dir(PIN_RGB_R, GPIO_OUT);
|
||||||
|
gpio_init(PIN_RGB_G);
|
||||||
|
gpio_set_dir(PIN_RGB_G, GPIO_OUT);
|
||||||
|
gpio_init(PIN_RGB_B);
|
||||||
|
gpio_set_dir(PIN_RGB_B, GPIO_OUT);
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
gpio_put(PIN_RGB_G, 1);
|
||||||
|
sleep_ms(250);
|
||||||
|
gpio_put(PIN_RGB_R, 0);
|
||||||
|
sleep_ms(250);
|
||||||
|
gpio_put(PIN_RGB_B, 1);
|
||||||
|
sleep_ms(250);
|
||||||
|
gpio_put(PIN_RGB_G, 0);
|
||||||
|
sleep_ms(250);
|
||||||
|
gpio_put(PIN_RGB_R, 1);
|
||||||
|
sleep_ms(250);
|
||||||
|
gpio_put(PIN_RGB_B, 0);
|
||||||
|
sleep_ms(250);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user