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

相关推荐
fruge5 小时前
Visual Studio 2022安装时共享组件、工具、SDK路径无法更改的问题
ide·visual studio
我狸才不是赔钱货11 小时前
DevOps:打破开发与运维之间的高墙
运维·vscode·docker·devops
我狸才不是赔钱货11 小时前
揭开命令行的面纱:终端、CLI、Shell的终极辨析
vscode·ssh·bash
空影星13 小时前
SiriKali,一款跨平台的加密文件管理器
python·编辑器·电脑·智能硬件
TLucas13 小时前
Layui连线题编辑器组件(ConnectQuestion)
前端·编辑器·layui
添砖java‘’19 小时前
vim高效编辑:从入门到精通
linux·编辑器·操作系统·vim
不吃凉粉20 小时前
Android Studio USB串口通信
android·ide·android studio
编程乐学21 小时前
安卓非原创--基于Android Studio 实现的天气预报App
android·ide·android studio·课程设计·大作业·天气预报·安卓大作业
非得登录才能看吗?1 天前
VScode 入门(设置篇)
ide·vscode·编辑器
Costrict1 天前
解锁新阵地!CoStrict 现已支持 JetBrains 系列 IDE
大数据·ide·人工智能·深度学习·自然语言处理·ai编程·visual studio