第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则会点亮

相关推荐
TOSUN同星31 分钟前
干货分享 | TSMaster DBC编辑器操作指南:功能详解+实战示例
数据库·oracle·编辑器·汽车·软件工程
LIN-JUN-WEI2 小时前
[ESP32]VSCODE+ESP-IDF环境搭建及blink例程尝试(win10 win11均配置成功)
c语言·开发语言·ide·vscode·单片机·学习·编辑器
MUTA️6 小时前
pycharm中本地Docker添加解释器
ide·python·pycharm
Ronin3058 小时前
【Linux系统】vim编辑器 | 编译器gcc/g++ | make/Makefile
linux·运维·服务器·ubuntu·编辑器·vim
织_网8 小时前
Visual Studio Code 中统一配置文件在团队协作中的应用
ide·vscode·编辑器
界面开发小八哥17 小时前
「Java EE开发指南」如何用MyEclipse创建一个WEB项目?(三)
java·ide·java-ee·myeclipse
花花鱼17 小时前
android studio 设置让开发更加的方便,比如可以查看变量的类型,参数的名称等等
android·ide·android studio
雷羿 LexChien19 小时前
从 Prompt 管理到人格稳定:探索 Cursor AI 编辑器如何赋能 Prompt 工程与人格风格设计(上)
人工智能·python·llm·编辑器·prompt
到底起什么网名才能不重名1 天前
使用各种CSS美化网页
前端·css·vscode·bootstrap·html
不知所云,1 天前
3. lvgl 9.3 vscode 模拟环境搭建 lv_port_pc_vscode-release-v9.3
ide·vscode·编辑器·c·sdl·lvgl vscode·lvgl模拟器