Light up the LED light (GPIO learning)

Light up the LED light (GPIO learning)

The first step: understand the principle logic.

(The same network label means that their lines are connected together). If you want to make the D1 indicator light on, you only need to control the GPIO68 pin to output a low level. If you want to turn off the D1 indicator light, you only need to control the GPIO68 to output a high level.
The schematic diagram is as follows:
insert image description here
insert image description here
insert image description here

Step 2: Create a project

reference connection

Step 3: Write the LED header file (.h) and source file (.c).

The header file should include LED-related macro compilation, LED function declaration and system function header file, and the source file should include LED GPIO initialization and LED-related function function implementation.

void LedInit(void)
{
    EALLOW;//关闭写保护
    //防止多个GPIO在被初始化时,会被优化。
    //如果没有保护,则在除了编写的第一GPIO不被优化,

Guess you like

Origin blog.csdn.net/qq_45159887/article/details/129773437