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

相关推荐
&&Citrus6 小时前
【杂谈】SNNU公共计算平台:深度学习服务器配置与远程开发指北
服务器·人工智能·vscode·深度学习·snnu
飞火流云8 小时前
vscode Linux下编译失败找不到文件
ide·vscode·编辑器
Trouville019 小时前
Pycharm软件初始化设置,字体和shell路径如何设置到最舒服
ide·python·pycharm
Piink9 小时前
VSCode基本操作
vscode·编辑器
就叫飞六吧13 小时前
找不到或无法加载主类 @C:\***\Local\Temp\idea_arg_file...
java·ide·intellij-idea
BD_Marathon13 小时前
【JavaWeb】VsCode的其他常见设置
ide·vscode·编辑器
landian00414 小时前
vscode对于txt格式文件使用tab缩进为3个空格
ide·vscode·编辑器
q***046315 小时前
[golang][MAC]Go环境搭建+VsCode配置
vscode·macos·golang
ZhongruiRao15 小时前
vscode windows免密登录Linux服务器教程 解决设置后仍需要输入密码的问题
linux·服务器·vscode
阿阿阿阿里郎16 小时前
Vscode+STM32CubeMX+Cmake联合开发教
ide·vscode·编辑器