这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » DIY与开源设计 » 电子DIY » Let'sdo2025第二期活动[智能手环DIY活动](过程贴)任务一

共1条 1/1 1 跳转至

Let'sdo2025第二期活动[智能手环DIY活动](过程贴)任务一

工程师
2025-09-09 13:24:14     打赏

简介

在上一篇文章中我们已经对环境进行了搭建,并且构建了固件。那么本章节我们将对应原理图来Toggle LED灯。


image.png

根据原理图得知,此块开发板上搭载的是一个RGBLED灯珠,其中使用LED0, LED1和LED2分别控制三颗LED的点亮。


image.png

根据代码的宏定义得知, LED1 是 红色, LED1是绿色,LED2是蓝色。


/******************************************************************************
 *
 * Copyright (C) 2022-2023 Maxim Integrated Products, Inc. (now owned by 
 * Analog Devices, Inc.),
 * Copyright (C) 2023-2024 Analog Devices, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 ******************************************************************************/

/**
 * @file    main.c
 * @brief   Hello World!
 * @details This example uses the UART to print to a terminal and flashes an LED.
 */

/***** Includes *****/
#include <stdio.h>
#include <stdint.h>
#include "mxc_device.h"
#include "led.h"
#include "board.h"
#include "mxc_delay.h"

/***** Definitions *****/

/***** Globals *****/

/***** Functions *****/

// *****************************************************************************
int main(void)
{
    int count = 0;

    printf("Hello World!\n");

    while (1) {
        LED_On(LED1);
        MXC_Delay(500000);
        LED_Off(LED1);
        MXC_Delay(500000);
        printf("count : %d\n", count++);
    }
}

原本的代码中之后LED1的点亮,我们把其他的也加上去

int main(void)
{
    int count = 0;

    printf("Hello World!\n");

    while (1)
    {
        LED_On(LED1);
        MXC_Delay(500000);
        LED_Off(LED1);
        MXC_Delay(500000);
        LED_On(LED2);
        MXC_Delay(500000);
        LED_Off(LED2);
        MXC_Delay(500000);
        LED_On(LED3);
        MXC_Delay(500000);
        LED_Off(LED3);
        MXC_Delay(500000);
        printf("count : %d\n", count++);
    }
}

然后使用Ctrl+ shif + b 打开构建选项,选择构建。image.png


构建完成。

image.png

然后进行烧录。

image.png


烧录成功,接下来我们来看下效果,

49eca0576edee3f20c4ebf4e93b5cc2e.jpg

016ec97dde39cc47740c956cca274f47.jpg




关键词: Let's do     MAX78000    

共1条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]