2022-04-19T19:58:40
This commit is contained in:
30
05_time/src/time.c
Normal file
30
05_time/src/time.c
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <stdio.h>
|
||||
#include "pico/stdlib.h"
|
||||
#include "pico/time.h"
|
||||
#include "hardware/timer.h"
|
||||
#include "hardware/gpio.h"
|
||||
#include "pico/binary_info.h"
|
||||
|
||||
const uint LED_PIN = PICO_DEFAULT_LED_PIN;
|
||||
|
||||
int main()
|
||||
{
|
||||
bi_decl(bi_program_description("Time"));
|
||||
bi_decl(bi_1pin_with_name(LED_PIN, "On-board LED"));
|
||||
|
||||
stdio_init_all();
|
||||
|
||||
gpio_init(LED_PIN);
|
||||
gpio_set_dir(LED_PIN, GPIO_OUT);
|
||||
|
||||
while (true)
|
||||
{
|
||||
printf("%u %u\n", to_us_since_boot(get_absolute_time()), time_us_32());
|
||||
|
||||
gpio_put(LED_PIN, true);
|
||||
sleep_ms(250);
|
||||
gpio_put(LED_PIN, false);
|
||||
|
||||
sleep_ms(2000);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user