第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 小时前
苹果电脑(mac系统)安装vscode与配置c++环境,并可以使用万能头文件全流程
c++·ide·vscode·macos·编辑器
妖灵翎幺6 小时前
C++ 中的 :: 操作符详解(一切情况)
开发语言·c++·ide
奔跑吧 android7 小时前
【vscode】【远程 ssh 开发】【环境搭建】
ide·vscode·ssh
森明帮大于黑虎帮11 小时前
Visual Studio 2008 自述文件
ide·visual studio
欧恩意11 小时前
【Visual Studio】调试时 memcpy 拷贝错误,擅自修改内存
ide·visual studio
vortex513 小时前
Visual Studio 编译选项详解
ide·visual studio
记忆偶然14 小时前
语音转文本技术方案评估与工具选型指南
ide·macos·xcode
赵域Phoenix16 小时前
快速打开jupyter
ide·jupyter
还有你Y17 小时前
VScode远程连接docker容器教程
ide·vscode·docker
汐ya~17 小时前
Cursor连接异常问题“Model not available/connection failed”解决:IDE内置代理配置,无需全局流量代理与虚拟网卡
python·编辑器·cursor