第11篇:ESP32vscode_platformio_idf框架helloworld点亮LED

第1篇:Arduino与ESP32开发板的安装方法

第2篇:ESP32 helloword第一个程序示范点亮板载LED

第3篇:vscode搭建esp32 arduino开发环境

第4篇:vscode+platformio搭建esp32 arduino开发环境

​​​​​​第5篇:doit_esp32_devkit_v1使用pmw呼吸灯实验

第6篇:ESP32连接无源喇叭播放音乐《涛声依旧》

第7篇:ESP32连接按钮点亮LED无源喇叭播放声音

​​​​​​第8篇:ESP32连接超声波HC-SR04测距点亮LED无源喇叭播放声音

第9篇:ESP32超声波HC-SR04Arduino类库编写

第10篇:ESP32外部中断功能的使用

请浏览第4篇搭建方法

第4篇:vscode+platformio搭建esp32 arduino开发环境,第7步新建项目,framwork选择Espidf

等待创建完成。

创建慢,检查配置文件:

建议连接手机移动共享的热点,首次创建预估10-20分钟左右。再次创建项目预估30秒左右

创建成功后目录:

打开main.c文件

cpp 复制代码
void app_main()
{
    

    gpio_set_direction(16, GPIO_MODE_INPUT); //设置D16引脚输入模式
    gpio_set_direction(2, GPIO_MODE_OUTPUT); //D2板载LED输出模式
    gpio_set_pull_mode(16, GPIO_PULLUP_ONLY); //D16上拉模式,默认是高电平
    gpio_get_level(16); //获取D16输入状态
     

   
 
    while (true)
    {

        // if (mLevel != (temp = gpio_get_level(16)))
        {
            temp = gpio_get_level(16); //获取D16输入状态
            // mLevel = temp;
            if (temp)//读取到1时
            {
                printf("HIGH Level\n");
                gpio_set_level(2, 0);
            }
            else   //读取到0时
            {
                gpio_set_level(2, 1); //D2设置输出HIGH,则是高电平,灯亮
                printf("LOW Level\n");
            }
        }
        usleep(1000 * 1000 * 3); //微秒,1000微秒=1毫秒,1000毫秒=1秒,延迟3秒
        // vTaskDelay(1000/portTICK_PERIOD_MS); //延迟1秒

 

  
        
    }
}

包含头文件名:

cpp 复制代码
#include "driver/gpio.h"
#include <stdio.h>
#include "unistd.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/event_groups.h"
#include <stddef.h>
#include <time.h>

#include <string.h>
#include <time.h>
#include <sys/time.h>
#include "esp_system.h"
#include "esp_event.h"
#include "esp_log.h"
#include "esp_attr.h"
#include "esp_sleep.h"
#include "nvs_flash.h"
#include "esp_sntp.h"
#include "esp_wifi.h"

编辑上传步骤参考:请浏览第4篇,第9步

第4篇:vscode+platformio搭建esp32 arduino开发环境

将D16用杜邦线连接GND,D16则输入了低电平,D2 LED则会点亮

相关推荐
无你想你6 小时前
利用vscode时进行调试,即使设置justMyCode为False仍然失败,如何解决?
ide·vscode·编辑器·justmycode
xcs194058 小时前
AI 自动化编程 trae 体验 页面添加富编辑器
运维·自动化·编辑器
Zeluar11 小时前
关闭VSCode Markdown插件在Jupyter Notebook中的自动预览
ide·vscode·jupyter
雷工笔记1 天前
【软件安装】VScode介绍安装步骤及中文界面设置方法
ide·vscode·编辑器
△曉風殘月〆1 天前
Visual Studio中的常用调试功能(下)
c++·ide·visual studio·调试
△曉風殘月〆1 天前
Visual Studio中的常用调试功能(上)
ide·visual studio·调试
gaog2zh1 天前
100202Title和Input组件_编辑器-react-仿低代码平台项目
react.js·低代码·编辑器
_poplar_1 天前
08.5【C++ 初阶】实现一个相对完整的日期类--附带源码
c语言·开发语言·数据结构·c++·vscode·算法·vim
翁正存1 天前
IDEA测试代码报java file outset source root异常
java·ide·intellij-idea
一枚小小程序员哈2 天前
基于Android的随身小管家APP的设计与实现/基于SSM框架的财务管理系统/android Studio/java/原生开发
android·ide·android studio