云端给开发板发送指令然后实现小灯翻转

This commit is contained in:
james 2024-07-31 00:35:11 +08:00
parent a0ae37543c
commit 43846001be
2 changed files with 10 additions and 8 deletions

View File

@ -51,10 +51,12 @@ static void example_message_arrive(void *pcontext, void *pclient, iotx_mqtt_even
rt_pin_mode(GPIO_LED_R, PIN_MODE_OUTPUT);
if(rt_pin_read(GPIO_LED_R) == PIN_HIGH)
{
// rt_kprintf("LED_R should be ON\n");
rt_pin_write(GPIO_LED_R, PIN_LOW);
}
else
{
// rt_kprintf("LED_R should be OFF\n");
rt_pin_write(GPIO_LED_R, PIN_HIGH);
}
EXAMPLE_TRACE("Topic : %.*s", topic_info->topic_len, topic_info->ptopic);

View File

@ -63,14 +63,14 @@
int main(void)
{
main_init();
rt_pin_mode(GPIO_LED_B, PIN_MODE_OUTPUT);
while(1)
{
rt_pin_write(GPIO_LED_B, PIN_HIGH);
rt_thread_mdelay(500);
rt_pin_write(GPIO_LED_B, PIN_LOW);
rt_thread_mdelay(500);
}
// rt_pin_mode(GPIO_LED_B, PIN_MODE_OUTPUT);
// while(1)
// {
// rt_pin_write(GPIO_LED_B, PIN_HIGH);
// rt_thread_mdelay(500);
// rt_pin_write(GPIO_LED_B, PIN_LOW);
// rt_thread_mdelay(500);
// }
return 0;
}