Forwarded from RT-Thread Community Developer luzixing
#include <rtthread.h>
#include <rtdevice.h>
#define LED_PIN1 21
#define LED_PIN2 22
void led_link(void *parameter)
{
rt_uint8_t count = 0;
rt_pin_mode(LED_PIN1, PIN_MODE_OUTPUT);
rt_pin_mode(LED_PIN2, PIN_MODE_OUTPUT);
while (1)
{
/* led1 on */
rt_kprintf("led on, count : %d <br>", count);
count++;
rt_pin_write(LED_PIN1, 0);
rt_pin_write(LED_PIN2, 0);
rt_thread_delay(RT_TICK_PER_SECOND / 2); /* ?? 500 ?? */
/* led1 off */
rt_kprintf("led off <br>");
rt_pin_write(LED_PIN1, 1);
rt_pin_write(LED_PIN2, 1);
rt_thread_delay(RT_TICK_PER_SECOND / 2);
}
}
MSH_CMD_EXPORT(led_link, led blink sample);
Experimental steps:
Results: